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