72

I currently have the following versions installed my windows machine.

node : v7.3.0 npm : 3.10.10 @angular/cli : 1.4.2

I would like to install latest versions of the above and be able to switch accordingly. To my knowledge installation of node governs that. If I need to install latest npm and angular cli then i would need to install the latest version of node. Please do correct me if I am wrong. Can i globally install the latest version of nodejs. Once I install that could i switch between the node versions. I presume switching between the node versions would take care to use the appropriate npm and cli.

8
  • 5
    There's a project called nvm-windows I've used before: github.com/coreybutler/nvm-windows Commented May 17, 2018 at 20:05
  • So if I install latest version of node and then say nvm use the new version and then install latest version of npm and angular cli, would switching between the node versions take the appropriate versions of npm and cli. So i believe when i install npm and angular cli they would be tied to that specific nodejs version installation. I am looking for that kind of ability to switch Commented May 17, 2018 at 20:23
  • 1
    According to the documentation: "Please note that any global npm modules you may have installed are not shared between the various versions of node.js you have installed." So yes, it sounds like they will be tied to the version of npm Commented May 17, 2018 at 20:29
  • Perfect that what i was looking for Commented May 17, 2018 at 20:32
  • I have installed node version v8.11.2. when i run nvm list i expected it to show both the versions but it shows only 7.3.0. When I run node -v it shows 8.11.0. if i execute nvm use 7.3.0 then i get a message node v7.3.0 (64-bit) is not installed. I am confused Commented May 17, 2018 at 20:43

7 Answers 7

57

nvm-windows let's you do that. Before installing nvm-windows, please uninstall all Node versions from your computer.

To install any Node version, type in command prompt nvm install [node version], like for example:

  • nvm install 10.16.0
  • nvm install 6.11.0

nvm list lists all Node versions you installed:

  • 10.16.0
  • 6.11.0

nvm use 6.11.0 

or

nvm use [version name] 

and you will be prompted by a windows pop up to allow nvm-windows to use/switch to a particular Node version.

Sign up to request clarification or add additional context in comments.

1 Comment

Also make sure you don't have an empty C:\Program Files\nodejs folder. If you do, just delete it before nvm use ....
54

This is achievable via various version managers.

For Windows, take a look at NVM for Windows.

For macOS or Linux (not your OS, I see, but for others reading), I like n, and NVM is also widely used.

5 Comments

I've kept the mac and linux info as it's likely that other people reading find this by searching for similar info. Windows is on top though. Thanks for the feedback!
So if I install latest version of node and then say nvm use the new version and then install latest version of npm and angular cli, would switching between the node versions take the appropriate versions of npm and cli. So i believe when i install npm and angular cli they would be tied to that specific nodejs version installation. I am looking for that kind of ability to switch
I would add, to answer the other parts of his question. Changing your node version does not effect your angular cli version in any way shape or form.
Nvm on windows not work with latests versions (10.x.x) of nodejs
for linux users: There is also a node plugin for asdf-vm
2

Many of companies policies have restricted use of NVM on windows due to several reasons. In such cases there is another way we can manage multiple versions on windows.

First uninstall all node versions from your system control panel. Then you need to either download the binary / archived versions from the node page.

Download from here https://nodejs.org/en/download

If you don't found your exact version from above page then please check from node dist - https://nodejs.org/dist/

  • select your version and then download : node-vXX.xx.xx-win-x64.zip. You can download multiple required versions

    eg for version 22.6.0 → node-v22.6.0-win-x64.zip

Then unzip the downloaded file, now add the location of unzip folder to path variable inside System environment variable.

NOTE : You need to close and restart all terminals to affect the changes.

If you need to change the version just update path variable to point point out another version location inside System environment variable and ready to use.

enter image description here

Comments

1

I set my node version default like this: nvm alias default <version>

Comments

0

For context, I needed to run different node versions across different terminals on windows, and found that nvm-windows does not support it because of the way it works as per Gabriel's answer on top.

Found this wonderful work on github - https://github.com/davfive/nvm-session and all credits to the creator, for building a simple workaround for this. The steps to get this working are clearly explained in the README of the repository, and helped me solve my problem!

However, I believe it requires you to use git-bash/any such bash-supported terminals on windows to get this working!

Comments

0

At the time of my answer, we have Volta that can install, switch, pin (remember version based on projects) between node, npm and yarn. Super awesome!

Comments

0

List of cross-platform version managers that work across Windows, macOS, and Linux:

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.