All language subtitles for 004 Using Node.js_en

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French Download
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranî)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:00,170 --> 00:00:06,140 So now that you've successfully installed a node, let's go ahead and see how we can use it to start 2 00:00:06,140 --> 00:00:07,939 creating applications. 3 00:00:07,970 --> 00:00:14,540 Now the first thing we're going to do is to perform a version check using this command in the command 4 00:00:14,540 --> 00:00:23,260 line node space, Dash V, go ahead and open up Visual Studio code and open up a new window. 5 00:00:23,270 --> 00:00:26,570 Now, in this new window, you won't have any files, you won't have anything else. 6 00:00:26,570 --> 00:00:27,830 But that's not important. 7 00:00:27,830 --> 00:00:31,550 We're going to go to view and we're going to open up the terminal. 8 00:00:31,550 --> 00:00:37,910 Now, another way to get to this is actually to hover down right to the bottom until you see this little 9 00:00:37,910 --> 00:00:38,780 arrow pop up. 10 00:00:38,780 --> 00:00:42,980 And if you click and drag it up, you'll also be able to open up the terminal. 11 00:00:43,160 --> 00:00:46,820 I'm going to get rid of anything that I don't need. 12 00:00:46,820 --> 00:00:55,970 And inside my terminal, I'm going to write that command Node V to check the version of Node and hopefully 13 00:00:55,970 --> 00:00:57,590 you're on the same version as me. 14 00:00:57,590 --> 00:01:01,410 If you've completed all of the installation steps correctly. 15 00:01:01,440 --> 00:01:08,130 Now, if you don't see the same version, it might be because you are on a more recent version, so 16 00:01:08,160 --> 00:01:09,660 maybe the number is higher. 17 00:01:09,720 --> 00:01:16,500 Alternatively, maybe you've installed Node in the past and you've got a lower version for some reason 18 00:01:16,500 --> 00:01:17,120 or other. 19 00:01:17,130 --> 00:01:23,310 Have a look at the text and the fix in the last lesson where we did the installation and you'll find 20 00:01:23,340 --> 00:01:25,830 some instructions on how to fix this. 21 00:01:26,160 --> 00:01:32,280 But hopefully when you check your node version, you should see a version number show up, starting 22 00:01:32,280 --> 00:01:36,300 with a V and it should be 18 or higher. 23 00:01:36,300 --> 00:01:38,910 So 19, 20, whatever it may be. 24 00:01:39,330 --> 00:01:44,190 Now that we've made sure that we've got the right version of Node, the next thing to learn to use is 25 00:01:44,190 --> 00:01:45,540 the node Repl. 26 00:01:45,540 --> 00:01:49,290 So Repl stands for read eval print loop. 27 00:01:49,290 --> 00:01:51,360 And this is not unique to Node. 28 00:01:51,390 --> 00:01:58,170 It's something that we can do with most programming languages and it's basically an environment like 29 00:01:58,170 --> 00:02:04,800 the node runtime environment where we can put in user inputs in the form of code. 30 00:02:04,800 --> 00:02:12,030 And what we write is read by the computer and evaluated line by line, and then it prints out the result 31 00:02:12,030 --> 00:02:18,690 back to us in the command line or in the console and to initiate the node. 32 00:02:18,690 --> 00:02:27,990 Repl all we have to do is to type the command node going back to our Visual Studio window, let's go 33 00:02:27,990 --> 00:02:31,560 ahead and type the node command here. 34 00:02:31,560 --> 00:02:37,350 It should tell you, welcome to Node and you should see this little arrow here which tells you that 35 00:02:37,350 --> 00:02:45,660 you have successfully entered the node repl Now in the node repl what we're going to do is we can type 36 00:02:45,660 --> 00:02:52,230 some commands such as the help that they've already told you about and this gives you some of the other 37 00:02:52,230 --> 00:02:53,490 commands that you can use. 38 00:02:53,490 --> 00:02:56,910 For example, Break Clear Editor ET cetera. 39 00:02:56,910 --> 00:03:03,180 But the most important one, because very often the hardest thing with Repls is how to exit them. 40 00:03:03,180 --> 00:03:09,930 We can use the dot exit to get out of this and you can see we no longer have that little arrow sign 41 00:03:09,930 --> 00:03:11,160 showing up anymore. 42 00:03:11,190 --> 00:03:12,450 That's ended. 43 00:03:13,470 --> 00:03:21,510 Alternatively, you can simply type control C and then control C again in order to exit. 44 00:03:21,540 --> 00:03:26,370 Now, control C is usually the way to get out of anything in the command line. 45 00:03:26,370 --> 00:03:32,220 So in the future, even if you see some sort of process running and you're not getting your usual command 46 00:03:32,220 --> 00:03:37,800 line interface, just try Ctrl C a few times and that should hopefully get you out of trouble. 47 00:03:37,800 --> 00:03:44,400 Now let's go back into the node Repl and I'm just going to raise this window up a little bit because 48 00:03:44,400 --> 00:03:51,960 I know that very often the subtitle goes at the bottom and it can be hard for students to read what 49 00:03:51,960 --> 00:03:52,860 I'm writing. 50 00:03:53,220 --> 00:04:00,210 All right, so inside our node Repl, let's try to do a read eval print loop, let's write some code, 51 00:04:00,240 --> 00:04:06,810 let's do something really simple like five plus eight hit enter and you can see it's read my code, 52 00:04:06,810 --> 00:04:09,720 it's evaluated it and then it's printed it out. 53 00:04:09,720 --> 00:04:13,290 So read, evaluate, print loop done. 54 00:04:13,290 --> 00:04:20,490 Now remember that Node is a JavaScript runtime, so you can write anything that is JavaScript. 55 00:04:20,490 --> 00:04:28,740 So let a equals three and then a plus 12 will work just as you would expect. 56 00:04:28,950 --> 00:04:36,060 Have a play around with the node Repl and hopefully by the end you'll see that this is really similar 57 00:04:36,060 --> 00:04:40,860 to what you've been able to do using the JavaScript console in the browser. 58 00:04:40,860 --> 00:04:47,100 But in this case we've just taken it out of the browser and we're using Node to enable us to run that 59 00:04:47,100 --> 00:04:48,330 JavaScript code. 60 00:04:48,540 --> 00:04:57,060 Now the final thing I want to show you in terms of using Node JS is how we can write a JavaScript file 61 00:04:57,060 --> 00:04:59,760 and use node to run the entire file. 62 00:04:59,940 --> 00:05:06,990 Because as useful as a ripple is in the command line, what we actually need to do is to write full 63 00:05:06,990 --> 00:05:10,680 code files and to use Node as the runtime environment. 64 00:05:11,040 --> 00:05:16,920 So head over to the course resources in this lesson and hopefully you'll see a zip file there called 65 00:05:16,950 --> 00:05:18,780 2.1 using Node. 66 00:05:18,780 --> 00:05:24,840 And I want you to download and extract that file and open that folder inside vs code. 67 00:05:24,840 --> 00:05:32,340 If you don't know how to access the course resources or how to unzip and actually get hold of the file 68 00:05:32,340 --> 00:05:33,360 and make it work. 69 00:05:33,360 --> 00:05:39,420 And if you've just skipped to this section, make sure you take a look at one of the earliest lessons 70 00:05:39,420 --> 00:05:45,000 in the course right at the beginning in Section one, where we talk about how to get hold of the course 71 00:05:45,000 --> 00:05:47,370 resources, it's really important. 72 00:05:47,370 --> 00:05:51,690 And if anything doesn't work in the next steps, be sure to review that. 73 00:05:51,870 --> 00:05:52,230 All right. 74 00:05:52,230 --> 00:05:58,110 But hopefully you've got this working and you can see in here all there is, is just a blank index.js 75 00:05:58,110 --> 00:05:58,740 file. 76 00:05:58,770 --> 00:06:02,050 But what's important is our folder structure. 77 00:06:02,290 --> 00:06:06,070 I want to show you how we can write code into this code file. 78 00:06:06,070 --> 00:06:09,010 I'm just going to write console log. 79 00:06:09,130 --> 00:06:13,560 Hello from Node and that's all we got. 80 00:06:13,570 --> 00:06:16,990 Let's hit save and let's open up our terminal. 81 00:06:16,990 --> 00:06:21,190 And the first thing I want to do is to navigate to that folder. 82 00:06:21,190 --> 00:06:23,980 So remember, we can use CD to change directory. 83 00:06:23,980 --> 00:06:29,590 And the directory I want to get hold of is the one that contains this index.js file. 84 00:06:29,590 --> 00:06:37,330 So I'm going to drag that folder to point one using node and then hit enter in order to navigate into 85 00:06:37,330 --> 00:06:39,100 that folder in the command line. 86 00:06:39,220 --> 00:06:45,850 Now that I'm here, I can use the node command and instead of just writing Node where we enter the Repl, 87 00:06:45,850 --> 00:06:49,030 I'm going to type in the name of my file. 88 00:06:49,030 --> 00:06:55,600 And one of the things that a lot of developers do when they are trying to access different files etcetera, 89 00:06:55,600 --> 00:07:01,810 is you can actually just type the first few words, hit the tab key on your keyboard and it should autofill 90 00:07:01,810 --> 00:07:04,810 the rest of the file name. 91 00:07:04,810 --> 00:07:09,850 On one hand, this is really great because you didn't have to type out the rest of the file name, but 92 00:07:09,850 --> 00:07:15,010 on the other hand, it's also a sense check for figuring out whether if you're in the right directory, 93 00:07:15,010 --> 00:07:22,810 because if I went up one level and I did the node index and you can see even if I keep hitting tab, 94 00:07:22,810 --> 00:07:23,710 nothing happens. 95 00:07:23,710 --> 00:07:27,940 There isn't a file called that in this directory. 96 00:07:29,230 --> 00:07:36,550 So let's go back into the folder that we want to be in and then go ahead and use Node and then add the 97 00:07:36,550 --> 00:07:43,750 name of the file We want to run, hit enter and you can see that Node has found this file, used the 98 00:07:43,750 --> 00:07:47,110 node runtime to run the code inside Index.js. 99 00:07:47,110 --> 00:07:52,540 And here we see the outcome, which is exactly what we would expect. 100 00:07:53,510 --> 00:07:54,440 There you have it. 101 00:07:54,470 --> 00:07:57,170 Hopefully this has worked just as well for you. 102 00:07:57,170 --> 00:08:04,340 And if you want some extra practice, I recommend creating another JavaScript file inside the same folder 103 00:08:04,340 --> 00:08:10,710 and write some code in there and use node to run that file just so you can have practice using node. 104 00:08:10,730 --> 00:08:16,070 But in the next lesson, we're going to move on to look at some of the native node modules and see how 105 00:08:16,070 --> 00:08:21,170 we can leverage them in order to add more power to our node applications. 106 00:08:21,290 --> 00:08:23,690 For all of that and more, I'll see you there. 11312

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.