06 - How to use nvm (node version manager) to manage your versions of node.js

The important bits

Transcript (auto-generated)

0:00 In this episode we'll demonstrate how to install nvm the Node version Manager. If you search nvm in Google, the first result will be the node version manager for Posix, which basically just means Linux, Mac, anything Unix-based. So, if you're on a Mac will chooses first version here, and if you're on Windows will choose the second version here, but this episode will demonstrate how to install and use the Mac version. Let's go down to the installation instructions installing and updating okay, So here's the recommended approach using Curl. I know when I got started with Web development. I would see commands like this and I think what on earth does this mean? So let me break this that quickly curl means download this file. So this here is a script. It's open this up. The first part Curl means download this file and then the pipe operator, and then Bash means. Run this file with the Bash language, so if this were a note file or joust profile, you could do pipe node, and it would try to execute as a note file, so it's going to download this script, and then it's going to run it as a batch file, which basically gonna install node, install node version manager, and much magic that we don't need to know about

1:21 it. Let's do that. Now I'm going to copy this and you'll go to your terminal and your pace this in revolut. Lets me. Emulate a terminal without having to manually uninstall and then reinstall and Vm locally on my laptop, which I don't want to do right now and we're going to run that command,

1:36 and it's downloading it. The installation is complete. A few things I'd like to point out here. Here. There's a helpful message currently have modules installed globally with N P. M. These will no longer be linked with the active or sham note when you install a node with envy 'em so from here on out and Vm is going to manage all of our node versions. That means when you npm install -g with the global flag (-g), it's going to be managed by this and via managed version of node. That means any previous models you installed with an Pm. Install Dash G have been kind of wiped out, so if you want those back, you'll have to redo that for each version that you're using, usually only using one verse at a time, so that's not too big of an issue, but just expect if you have Eslint prettier, Nfl gotta sell globally. You'll have to reinstall that and then the other thing here. We can simply close and reopen the terminal and then it'll load and Bm. So let's do that. Now Okay, I have no close my tab and reopened it. So now we should be able to type and Vm and that's the same as typing and Vm Dash Dash help, which gives us all of the options here. Let's just focus on the most important ones. So Envy M L S shows us what versions we currently have so it's got a system. It's got Io. Js. Note, stable, unstable. Let's just ignore all of these. We would like to install some new versions. And here are really the most important commands you really need to worry about install. Use Run is a way you can run a node application or a script with just a certain burden, which is kind of cool, and then you can alias your defaults sold. Demonstrate some of those now looks like the system currently has burden tenant salt. I want to solvers, and twelve and Bm install twelve, and it's in selling and twelve at eighteen. Not three looks like that's the latest version within twelve, and it's creating an alias for us. Helsing default to twelve, so now I do envy him. Ellis again, Sue got Version twelve installed. A default alias is mapped. Twelve great novelty. No dash, be we aversion, Twelve fantastic. Now I wanna live on the bleeding edge, So what if I want, fourteen, two, and Vm install fourteen,

3:44 so you may have noticed that it didn't show the Alias command, because it detects that Twelve was the first version we installed.

3:51 Let's see. So I have twelve. We have fourteen, and default is still set at twelve, so that's helpful. So what is the forming here Default means any time you open up a new tab that was going to be loaded by default, so you can easily switch back and forth by using envy him use to go back to twelve, so I'm now using Version twelve and be amused. Fourteen, and any time I close my tab and reopen it. It'll go back to that default version,

4:20 so say. My team has upgraded to Version fourteen and I want to sit that. As the default envy him alias default, cause, I'm going to elias this to this version, so I'm going to alias default. Two fourteen.

4:38 So, now all of a sudden, if all just fourteen and I can do nvm use default, If I want to as well, and we don't need to worry about these names. These are all the LTS code names. So these are also alias Erbium. Is the coding information Twelve have you could do nvm use lts/erbium. Personally, i've never found it very useful

5:02 to go back to default

5:05 in summary, nvm is incredibly useful for managing different versions of node, and is especially helpful if you want to try new features. Go on a trip that your app is running well on the latest version as well as the current version and Vm help solve all those problems good at and be ambitious Help. These are really the most important commands install use an alias. Are the ones I just demonstrated his others here if you want to use those, and as a final reminder, after you install, and Yam graphs, you install a new version of node using Mbm. We may need to globally reinstall some of your glow modules like prettier, earliest Lent, or whatever you have installed globally, That's it. Good luck.

END