In the next video we are going to do an exercise and in this 1
exercise we won't really need to execute our code in a 2
browser okay because we're not going to create a UI or 3
anything we just want to be able to run some typescript 4
okay and see directly the result in your terminal but for 5
now when you run the command TSC on your file like this with 6
the watch you're basically just saying I want to compile my 7
file but I'm not executing it okay that's what the browser is 8
doing when we were using Chrome Chrome was reading your 9
JavaScript file, the JavaScript file that has been generated 10
right but here well we're not saying to our terminal, our 11
laptop, to read the JavaScript file and execute it okay and 12
and and produce the results so that's basically what you could 13
do by running a node on your machine so for example here my 14
index.ts has already been compiled okay so you have an 15
index.js and by the way for now I just have this in my 16
index.ts okay so Here is the js file that has been generated 17
which is fine and if I just run node then target my index file 18
it's going to work okay so we want basically something that 19
is going to watch our TSC file and anytime it's going to 20
change we want the node command to run alright so to do that 21
we're going to need two libraries that are two famous 22
libraries actually so you can install them by typing NPM I and 23
you're going to install TS node so TS node will be in charge of 24
compiling typescript file like TSC but as soon as it's going 25
to be compiled it's going to run node on the javascript file has 26
been produced and we're going to need something that will 27
watch any change in the project to rerun the TS note command 28
and so the library that we need is Nodemon and you can install 29
that globally like this once it's done you can go back in 30
your package to json and so now we don't need to watch 31
anymore and we don't need TSC we can just write Nodemon like 32
this on this file so Nodemon is going to run behind the scene 33
TS node on this file anytime this file changes and now I can just 34
run NPM start and as you can see nodemon is starting it's going 35
to run TS node on this file it's going to compile it and 36
then run node on the javascript file has been produced and I 37
will see my result and the cool thing is that now if I go here 38
and add something: "hello" , I'm going to save it going to 39
recompile you're going to see the output directly in your 40
terminal okay so that's useful when you are not working on web 41
application for example alright So for now in the next exercise 42
we're going to work like this because we don't need a UI, 43
okay? So see you on the next one.