56

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.

Tom
  • 8,175
  • 41
  • 136
  • 267
  • 4
    There's a project called `nvm-windows` I've used before: https://github.com/coreybutler/nvm-windows – user184994 May 17 '18 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 – Tom May 17 '18 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 – user184994 May 17 '18 at 20:29
  • Perfect that what i was looking for – Tom May 17 '18 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 – Tom May 17 '18 at 20:43
  • Angular cli has nothing to do with your node version. – Zachscs May 17 '18 at 20:52
  • I am not referring to angular-cli version. I am currently having node version 7.3.0 and 8.11.0 installed – Tom May 17 '18 at 20:55
  • is there any particular sequence of installing different versions of node? – Tom May 17 '18 at 22:02

3 Answers3

50

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.

Ian Paschal
  • 772
  • 4
  • 13
  • 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! – Ian Paschal May 17 '18 at 20:12
  • 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 – Tom May 17 '18 at 20:26
  • 1
    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. – Zachscs May 17 '18 at 20:51
  • Nvm on windows not work with latests versions (10.x.x) of nodejs – user2972221 Aug 22 '19 at 14:47
  • for linux users: There is also a node [plugin](https://github.com/asdf-vm/asdf-nodejs) for [asdf-vm](https://github.com/asdf-vm/asdf) – Melchior Jun 11 '21 at 11:23
38

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.

Bioukh
  • 1,888
  • 1
  • 16
  • 27
Sukhpreet Singh
  • 501
  • 4
  • 4
0

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

harp
  • 79
  • 7