Check out a free preview of the full Full Stack for Front-End Engineers, v2 course:
The "Node.js Configuration" Lesson is part of the full, Full Stack for Front-End Engineers, v2 course featured in this preview video. Here's what you'd learn in this lesson:

Jem defines Node.js as a JavaScript runtime system that runs on the Chrome V8 engine, explains why node is useful to install on a server, and how to install it.

Get Unlimited Access Now

Transcript from the "Node.js Configuration" Lesson

[00:00:00]
>> Jem Young: All right, so that that's fine and nginx, like I said, it's a web server. So we can serve static HTML pages and all that. But at some point, we wanna create complex applications. Applications that have different paths, different ways of maybe connect to a databas. Just coding, kind of more akin to what we do in our day to day.

[00:00:19] To do that, we're gonna create an application server. And that's different from a web server. And the web server's just receiving a lot of web traffic and doing something with it. The application is doing all the heavy lifting. For our application today we're gonna use NodeJS. My website is built in Python using Flask, but I won't go that route today.

[00:00:36] Let's do NodeJS because, well, most of us know JavaScript, I'm assuming. If not, there's a lot of courses on NodeJS, will add links to those in the future. And we'll get more into more details into NodeJS but for now I wanna create the most basic web server.
>> Jem Young: What is NodeJS though?

[00:00:54] Can someone tell me just like what it is? And it seems like a really simple question but if you're asked a simple questions you're, it's that thing that runs JavaScript. What is NodeJS?
>> Speaker 2: JavaScript environment for the server side.
>> Jem Young: I'll take that, yeah, yeah, that's right.
>> Speaker 2: Yeah, that but it's also a binding for the V8 engine that Google developed for Chrome.

[00:01:23]
>> Jem Young: Yes.
>> Speaker 2: It's one of the most performant just-in-time LLVM compilers out there.
>> Jem Young: Yes, everybody had bits of it correct and altogether, we're all right, which is good, that's why we're in a course. All right, it is essentially just a JavaScript engine that runs on top of V8, which is developed by Google Chrome.

[00:01:46] It's usually a few versions behind, so Chrome has features that Node doesn't actually support yet. But essentially, it's a single threaded JavaScript engine that executes JavaScript and can handle requests, that's it. The single thread in this is something that as we engineers, we probably don't appreciate. So, that means if a request comes in, it can handle things being asynchronous very very very well.

[00:02:13] So much so that we can use that JavaScript Lambda, of course request on block. But in Python or Java or in most other languages request block. So that means if I make a single request for a very large image file, and that's a fetching from, I don't know, London, it's gonna take time.

[00:02:29] And that means every other request that comes in is gonna get blocked, waiting for the other requests to resolve versus running a node. Node is asynchronous, it says, hey, I wanna get this image. I'm gonna go get this image, in the meantime, I'm gonna go handle all these other requests.

[00:02:43] And that's what's known as the event loop, is just constantly running over and saying like, is there anything to do? Is there anything to do? That's a really powerful concept, you probably won't appreciate it to switch languages. And you're you're dealing with blocking requests, you have to handle request keys and things like that.

[00:02:56] Whereas Node just handles that seamlessly. That's why Node is usually my go-to when it comes to creating a web server cuz it just handles things really well. Is it the fastest? No, Java is generally gonna be faster or Go or Rust. Or many other languages, it's not the fastest languages.

[00:03:12] But if anybody wants to nerd debate you, which people do, just be, Node does what I need. And most of the time you're not gonna be limited by the speed of the engine that is running. It's gonna be something else, like the code you wrote. You will at some point gonna hear a debate about what's better, especially, if you get to talking to C developers and things like that.

[00:03:34] Sorry, that was a tangent, let's install Node. [LAUGH] We're gonna install NodeJS along with npm. So sudo apt install nodejs npm, so install both of them at the same time.
>> Jem Young: So I'm gonna go ahead and do that, sudo apt.
>> Jem Young: Yes.
>> Jem Young: If you're wondering why I said NodeJS and not Node, Node originally was a radio application for Linux.

[00:04:12] For the longest time, if you installed Node it would install this application. But people got really annoyed at it because they're, who uses this versus the number of people that use Node? So now it's just NodeJS and it's gonna take over, if I type in Node, it's gonna use that.

[00:04:25] In the previous version of the class actually had a symbolic link it back. So I make a symbolic link to the actual NodeJS so Node equals Node JS, rather than typing NodeJS every time. Nerd trivia, didn't need to know, but we've come a long way in JavaScript. There's a time when Node was looked down, it's, JavaScript's for the back end.

[00:04:44] Now Netflix runs, I won't say entirely on Node, but runs largely on Node and JavaScript. With other parts written in various languages, mostly Java. But don't let anybody give you crap, if they talk about Node, that's all I'm saying. And we're done, and I'm gonna install Git, too.

[00:05:01] It's usually installed by default, but this is future-proofing ourselves. So oops, forgot the sudo, sudo apt install git. And it's usually installed already, but just in case, we'll make sure Git is installed.
>> Jem Young: So just apt install git for our version in control.