What is nvm
Node Version Manager is... a node version manager. It allows you to easily change the node version, this comes really helpful for example when you work on multiple projects with different NodeJS versions.
You can change your node version instantly with a single command - cool ๐
Installation
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
After the installation is complete you should add the last three lines you see above in your shell configuration file (which means copypasting them in ~/.bash_profile
or whatever you are using). After this, you should restart your terminal to use nvm
.
Check this link for the latest version and more details on how to install nvm
on your machine (macOS and Linux).
[Based on my own experience I can't recommend using Windows for web development - But you can google "nvm windows" for a Windows-compatible implementation of nvm].
Usage
First of all, install your favorite node version: nvm install 10
. If you don't specify an exact version, nvm will download the latest version automatically.
After installing any version of NodeJS with nvm
you can easily switch to that version by running nvm use <version>
.
Now you're ready to go.
Useful commands
-
nvm ls
shows the node versions you installed -
nvm ls-remote
shows all the node versions available -
nvm install <version>
installs the specified version -
nvm uninstall <version>
works like theinstall
command -
nvm alias default <version>
sets your default node version
Tips & Tricks
When you run nvm install
inside a directory if you have a .nvmrc
file, nvm
automatically installs the version specified in the .nvmrc
file.
This is very useful if you working on a shared project and need a specific NodeJS version.
Please comment if you have any suggestion or if you liked the post
Top comments (4)
You can use linux subsystem in Windows and it will work just fine. At least it did for me in the last 2 years
Which terminal is that in the pictures? I love the resource monitor
I used to work in a company that used windows for the development environment, I was using the terminal on the Linux subsystem while editing the files on windows.
This was corrupting the files and making them unreadable on both systems to the point that I had to restart the computer.
My understanding is that both systems had different permission systems and this was making the files unreadable from both sides
you can just use chocolatey.org/ or npmjs.com/package/n on windows