DEV Community

Cover image for How to use multiple versions of node on Windows
Mateusz Hadryś
Mateusz Hadryś

Posted on • Edited on • Originally published at Medium

How to use multiple versions of node on Windows

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?

nvm-windows to the rescue!

It's a fully-featured command line node version manager for Windows. It even comes with a simple gui installer, which is great.

Here are the steps to getting up and running with nvm-windows

  1. 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")
  2. Get the installer from the releases page: https://github.com/coreybutler/nvm-windows/releases
  3. Go through the installation process, nvm will be added to your PATH automatically
  4. Run cmd or any terminal emulator you might be using
  5. Use the command nvm install version_number where version_number is the version of node you want to install (e.g. 8 or 10)
  6. Repeat the above command for every version you need
  7. Finally, run nvm use full_version_number where full_version_number is the full version of node you want to currently use (e.g. 8.16.0 or 10.0.0)

Can I use Yarn with nvm-windows?

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.

What about WSL?

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.

More info

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

Thanks for reading

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.

Other articles you might enjoy

Top comments (0)