
Introduction to Node.js, v2 Installing Node.js
Transcript from the "Installing Node.js" Lesson
[00:00:00]
>> What is Node js? Well, Node js is JavaScript kinda like what I said before, but more specifically it's a runtime built on Chrome's V8. If you've never heard of Chrome's V8, it's the engine that sits inside of Chrome that actually compiles your JavaScript down to machine code.
[00:00:17] So it can be processed because JavaScript actually has to be interpreted and executed on a machine. V8 is the engine that does that. So some really smart person decided to strip V8 [LAUGH] out of Chrome and stick it on a machine. And that allows you to run Node and that's basically what we have here and everything is built on top of that.
[00:00:37] So just like on the front end, JavaScript and Node is also gonna be based off an event loop, which if you don't really know what that means, we'll get into it a little more but just know is that JavaScript is single threaded. As in, it's only going to be able to process work and amount of work in one little isolated instance.
[00:01:01] And then everything else kinda runs in the background. This allows Node to be able to process things much faster than a lot of other OS level languages, as long as those tasks are not CPU bound. So if you're not doing things like arithmetic or AI or machine learning, Node js is probably a perfect tool for you because it can handle things and put them in the background and continue to stay open to handle incoming requests and things like that.
[00:01:27] So that's why it's a very popular tool because it kinda allows you to scale a lot faster for smaller tasks like API's, which are like 90% of back end apps these days anyway. So that was a whole lot. Well, we're gonna cover a lot of that stuff. And like I said, here's the some of the use cases that I think are really, really good for Node js.
[00:01:46] Some of the things you see in the wild, some of the things that I've used personally, myself, so things like API's and servers, which we are gonna cover today, we're gonna be going over that and how to do that. Databases, yes, there're literally are some databases built in JavaScript.
[00:02:02] And it kinda blows my mind how people get away with this cuz I've looked at source code I'm like, first, I don't even know how to make a database. And second of all, the fact that you did it in JavaScript is just even more amazing. But yeah, I've seen databases built in Node.
[00:02:14] CLI, so a command line interface, if you've ever used Git, you've ever used anything in your terminal, your command prompt that was a command line interface. We're also gonna be covering some of that as well. So you'll be making your own CLIs build tools and automations. If you're a front end developer, you're probably familiar with something called Babel, maybe even TypeScript, Webpack, roll up.
[00:02:34] All those tools are built and executed in the Node runtime. So If you've never used Node as a front end engineer, but you've used those tools, well, you have been using Node this whole time. Because those tools execute in Node before your app actually gets deployed to the browser, that's what Node is doing.
[00:02:51] Basic scripting, you want some automation set up to do some shortcut get commands, you wanna have some basic commands in your terminal that don't exist, you can do that. Simple automations that open up a browser and buys a pair of sneakers for you, stuff like that. And like I said, [LAUGH] GPU shopping for bots, because no one can buy a GPU right now.
[00:03:11] You could pretty much do all this stuff in Node, and more, and we'll be covering a lot of it. So I'm super excited. So let's jump right in, and get started with Node js. So the first thing obviously is we need to install Node js and there are a few ways to do it.
[00:03:28] And it also depends on the machine that you're on. So for the windows folks out there if you're not running WSO or WSO2, which is a Linux environment embedded inside of windows. If you don't have that, then I do recommend going to the official Node.js installer on the nodejs.org website, where it will detect your operating system and it will allow you to download it.
[00:03:54] Mine says mac because I'm on a mac, if yours is windows it will probably say windows. So I recommend installing it that way. But if you if you aren't on Windows, or anyone else who's not windows basically, I do recommend using something called nvm or Node Version Manager.
[00:04:11] And the definition is in the name, it's literally a tool that manages different versions of Node on your machine. And the reason why I recommend this is for a few reasons, one it's very convenient to be able to switch to different versions of Node. Because different versions of Node have different features, different language support and things like that.
[00:04:30] So you can apply your app to different targets, it's great for testing, great for determining what version you need on a deployment platform which is very useful. And then also on a Mac, at least in my experience and working with others when you install from the official source, sometimes you have permission errors with the folders where Node actually gets installed.
[00:04:50] You just kinda have to Sudo everything and it just gets really crappy. So to avoid that Node Version Manager just doesn't work around and doesn't install inside of that folder that causes those permission errors. So yes, I highly recommend nvm, you click on that link that I have and you go to their repo.
[00:05:07] If you scroll down you'll see a nice copy and pastable curl thing here that you can paste and run and it'll pretty much get you set up and good to go. So if you don't have node installed yet, I do recommend installing it. If you do have Node installed, we are gonna use a specific version.
[00:05:25] And the one that we're gonna use is going to be the latest LTS or was it long term support or Lifetime support? It's one of those, it's the one that they plan on supporting on the long run for now, although it's not the absolute latest, 16 would be the latest but it's not the latest LTS.
[00:05:42] So we're gonna use the latest LTS, which right now is 14.7.0. So if you don't have that version, I would at least recommend downloading version 14 at the minimal to make sure you have some of the things that we're gonna cover in this course. Because we are gonna be using some of the bleeding edge things because I want this course to be somewhat future proof and I don't want to teach outdated things and older versions.
[00:06:04] So yes, I highly recommend downloading at least version 14 here to be able to keep up with what we're doing. If you do download version 16 you should be more than fine, there's nothing wrong with that. I just want to support the long term support version of Node js.
[00:06:21] Okay, and once you have nvm installed, you could actually just run this command right here in nvm install -- LTS. And it's just gonna install that latest version for you, so you don't have to figure out which one it is. If you don't put that LTS flag, I think it will install version 16, which again is also fine as long as it's at least 14.
[00:06:40] So whatever you wanna do, install that latest version, so we can get going, and making some stuff.