How to install and use Node Version Manager (NVM)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hey everyone welcome back to the channel uh just a quick video today to show you how to install and run multiple versions of node on your machine when i first started working with node i would just install it directly from the node.js website by using their recommended installer so i'll just click here and it would download the installer for my operating system and then i would run the installer and get the latest version of node and npm installed on my machine and start my new project but because node evolves so quickly and it feels like there's a new upgrade almost like every other month or there's a new version of note almost every other month by the time i was ready to start my new project i would have to then update to the latest version of node so that i could get the latest and greatest features in my new project and then as i was working on my new project about halfway through i would decide to revisit my old project and i would go into my old project run npm start and i would just be greeted by a whole bunch of uh red error messages about all kinds of npm packaging incompatibilities etc etc and this is super frustrating because i knew that my project ran on node and things were working just fine and all of a sudden i've got all these errors that i have to take care of enter node version manager or nvm for short what node version manager allows you to do is to install and manage multiple versions of node on your machine so that you can quickly switch back and forth between them based on your project requirements so what we're going to do first is install nvm and then once nvm is installed we will install multiple versions of node onto nvm and i'll show you how you can switch back and forth between them and do some other things i'm going to go to google here and just type in node version manager and this is running a little slow for me because i am on a virtual machine so that i could get a clean install of mac os all right and we're going to click on this first result here that just takes us to the nvm github page or repo so we're going to click on installing and updating and so to install or update nvm you should run the install script to do that you may either download the run script manually or use the following c url or w get command so i'm just going to grab this c url command whole thing here i'm going to open my terminal and let me make this a little bit bigger so that you folks on mobile screens can see it you can see well all right so i'm going to paste that c url command in here now the only thing i'm going to change is i'm going to change this from bash to zsh and the reason being is mac os i think after catalina they switched the command line shell over from bash to zsh and also keep in mind i am on mac os and uh the windows instructions i believe are very similar so if you are using windows you should be able to just go through this process in a very similar way all right and that's it it's now installed so what this did is as you see here it it wrote a little entry into my zshrc file and so if i go and peek into it i could see that i've got some stuff written in here and this is just a quick i think bash script just to install nvm globally so that i could use it as a command so what i'll need to do then is close my terminal and then start over so that all the changes can take effect all right so now if i type in nvm you can see that i've got nvm gives me a whole bunch of help instructions here so that i can so that i can get started so i'm going to just run you through a few commands so the first thing i'll do is i will install the latest version of note so it's pretty simple all you have to do is just run nvm install node and if i just put in node it'll just install the latest and greatest version of node so i think that would be version 15 as of this recording that was a pretty quick install so now i can go to node version and you can see i have the latest version of node 15.1.0 installed and then i can also type in npm version and that gives me the latest version of npm now the other thing i can do is i can say nvm ls and this will list all of the versions of node that i have installed it lists a whole bunch of other stuff here which honestly i don't know what any of this is but what i what we really care about is this thing right here and this is like this little arrow shows that that is my current um version that is activated now i could actually point to a specific version of node so because i ran nvm install node it just downloaded the latest version but i could type in nvm install and then i can actually point to a specific version so let's say i want to install 10 13. so now it's downloading version 10 13. there we go and uh if i do nvm ls again i could see that i have both 10 13 and 15 and as you see um it automatically switched me to the latest version that i installed so i would if i wanted to switch back to 15 i could just type in nvm use 15.1.0 and that will switch me back to 15. so if i just type in node version i am back in 15. i can also so i was typing in node version but i could also just type in nvm currents and that will give me my current version and the last thing i'll show you is how to uninstall a version of of node so um as you probably guessed the command would be nvm on install and then i could uninstall well first let me let me check which versions i have because i forgot already so let's say i want to uninstall 1013 so i would type in nvm uninstall version or actually i would just type in 10 13 0 hit uninstall and it's going to go through and uninstall that version and so now if i oops clear gosh i will just type in nvm ls and as you can see i'm now back on 15 1 and 10 13 is completely removed from my system there's one thing to keep in mind and that is if you switch between different versions of node any global npm packages that you have installed will not come along because these are completely independent installations of node basically if you have a package that like a global npm package that you installed on one version and um you're already using it you'll have to install the same package on another version so let me just give you an example here let me install 1013 again so i'll type in nvm install 10 13 0. and so i should be on 10 13 0 now so let me type in ls yep i'm on 10 13. let's install live server so i'll type in npm install g for global and then live server so now if i type in live server help i could see that i've got live server installed now if i switch to a different version so if i type in nvm use 15 and by the way you can just use 15 if you only have one version of 15 installed and now if i try to type in live server help it says the command is not found and that's because i installed live server on version 10. so it doesn't come along when i switch to a different version so yeah just a quick video i hope you found it helpful if you have any questions or comments please leave them down in the comment section below i've got a whole bunch more videos planned so if you haven't yet subscribed to the channel please subscribe and like the video and i'll see you in the next one thanks for watching
Info
Channel: Dev Café
Views: 17,459
Rating: undefined out of 5
Keywords:
Id: ohBFbA0O6hs
Channel Id: undefined
Length: 9min 59sec (599 seconds)
Published: Tue Nov 10 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.