Whether you're coming from linux, or are new to node. You're probably going to need to work with multiple versions of node at some point. Whether you're working on multiple projects or want it for testing purposes, a node version manager is a very useful tool. On linux it's easy, just install nvm and you're set. On windows it's not that simple... or is it?
It's a fully-featured command line node version manager for Windows. It even comes with a simple gui installer, which is great.
- If you have any version of node installed already, make sure to uninstall it first. Make sure to also remove any remaining node and npm directories (e.g. "C:\Program Files\nodejs" and "C:\Users<user_name>\AppData\Roaming\npm")
- Get the installer from the releases page: https://github.com/coreybutler/nvm-windows/releases
- Go through the installation process, nvm will be added to your PATH automatically
- Run cmd or any terminal emulator you might be using
- Use the command
nvm install version_numberwhere version_number is the version of node you want to install (e.g. 8 or 10)
- Repeat the above command for every version you need
- Finally, run
nvm use full_version_numberwhere full_version_number is the full version of node you want to currently use (e.g. 8.16.0 or 10.0.0)
Yes... but... Unfortunately, there are some issues with using yarn alongside nvm-windows. Basically, if you want to use yarn with nvm-windows, you will have to uninstall yarn (If you installed it using the gui installer). Then you will have to install it using
npm install --global yarn every time you switch the node version. There are also issues when installing packages globally with yarn (https://stackoverflow.com/questions/43108816/can-yarn-and-nvm-coexist-on-windows), so you may have to use npm for that anyway.
If you're coming from linux you might be tempted to try running the regular nvm on WSL. It might work for you, but I personally had many issues with it, so I don't recommend it. WSL2 might solve those issues though, so fingers crossed.
If you need further information, run
nvm without any arguments to show the list of available commands or visit the GitHub page of the project: https://github.com/coreybutler/nvm-windows
When I first found nvm-windows I thought it would be hacky and difficult to set up, but it surprised me, so I decided to write this to show others how easy node version management actually is on Windows.