104

I am trying to downgrade my version of node

I ran:

npm install nvm

and I exported the bin folder to my Windows path variable,

C:\Program Files (x86)\nodejs\node_modules\npm\bin

but I still get:

'nvm' is not recognized as a an internal or external command.

Should I be adding another path to my path variable?

G.S
  • 10,413
  • 7
  • 36
  • 52
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
  • 1
    using `scoop`: https://medium.com/around-the-app-in-365-days/setting-up-a-pc-63409ee7ab33 – XoXo Sep 13 '19 at 12:04

13 Answers13

122

nvm was designed for Linux. nvmw, which is completely different, broke around node v0.10.30. Try NVM for Windows.

urig
  • 16,016
  • 26
  • 115
  • 184
Corey
  • 5,133
  • 3
  • 23
  • 24
  • If we uninstall node js while install nvmw then how nodejs will work afterward? Please guide. Do we need to reinstall nodejs? – Always_a_learner Apr 24 '18 at 13:02
  • Corey I have intsalled nvmw and run nvm install 9.10 to install node version 9.10. now I have path C:\Users\simer\AppData\Roaming\nvm\v9.10.0 and C:\Users\simer\AppData\Roaming\nvm\v9.10.0\node_modules\npm node and npm both path are not working and not recognized as command. Please help. – Always_a_learner Apr 24 '18 at 13:16
  • 1
    @Simer - these should be written out as new questions. Before you do do, check the closed issues at github.com/coreybutler/nvm-windows because there are several answers to your second question. – Corey Apr 26 '18 at 02:59
  • 2
    FWIW, there is also one called [`nodist`](https://github.com/nullivex/nodist). I haven't tried it but in the past have run into problems with `nvm-windows` related to needing to run as administrator, having paths with spaces, using shells other than `cmd.exe`, etc. Though, just now I see that Corey's putting some TLC into this again (automated releases and such), so perhaps those are about to become history. – jacobq Sep 27 '19 at 22:13
  • For future reference: NVM for Windows does not support `.nvmrc` files, and the [developer explicitly stated](https://github.com/coreybutler/nvm-windows/issues/128#issuecomment-184858936) in one of the issues that he won't accept any PRs on that regard either. – starikcetin Dec 16 '20 at 21:09
  • See https://github.com/coreybutler/nvm-windows/issues/190 for how I intend to enable nvmrc-like capabilities using hooks. This will be part of "rt" (the successor to NVM4W that I'm working on... see https://github.com/coreybutler/nvm-windows/discussions/565) – Corey Dec 16 '20 at 21:31
107

NVM can be used to manage various node version :

  • Step1: Download NVM for Windows

  • Step2: Choose nvm-setup.zip

  • Step3: Unzip & click on installer.

  • Step4: Check if nvm properly installed, In new command prompt type nvm

  • Step5: Install node js using nvm : nvm install <version> : The version can be a node.js version or "latest" for the latest stable version

  • Step6: check node version - node -v

  • Step7(Optional)If you want to install another version of node js - Use STEP 5 with different version.

  • Step8: Check list node js version - nvm list

  • Step9: If you want to use specific node version do - nvm use <version>

Corey
  • 5,133
  • 3
  • 23
  • 24
Ritu Gupta
  • 2,249
  • 1
  • 18
  • 11
7

NVM Installation & usage on Windows

Below are the steps for NVM Installation on Windows:

NVM stands for node version manager, which will help to switch between node versions while also allowing to work with multiple npm versions.

  • Install nvm setup.
  • Use command nvm list to check list of installed node versions.
  • Example: Type nvm use 6.9.3 to switch versions.

For more info

6

As an node manager alternative you can use Volta from LinkedIn.

Claudiu
  • 3,700
  • 1
  • 38
  • 35
3

I created a universal nvm that works on both Unix (bash) and Windows, base on another simple nvm.

It doesn't need admin on Windows, but requires PowerShell 4+ and the right to execute scripts.

https://www.npmjs.com/package/@jchip/nvm#installation

Joel Chen
  • 270
  • 3
  • 7
  • the only one that worked for me without admin rights. Would love to see the library keeping on support – leachim Oct 05 '21 at 13:35
2

The first thing that we need to do is install NVM.

  1. Uninstall existing version of node since we won’t be using it anymore
  2. Delete any existing nodejs installation directories. e.g. “C:\Program Files\nodejs”) that might remain. NVM’s generated symlink will not overwrite an existing (even empty) installation directory.
  3. Delete the npm install directory at C:\Users[Your User]\AppData\Roaming\npm We are now ready to install nvm. Download the installer from https://github.com/coreybutler/nvm/releases

To upgrade, run the new installer. It will safely overwrite the files it needs to update without touching your node.js installations. Make sure you use the same installation and symlink folder. If you originally installed to the default locations, you just need to click “next” on each window until it finishes.

Credits Directly copied from : https://digitaldrummerj.me/windows-running-multiple-versions-of-node/

2

I will list two ways. You can choose one Whichever works for you.

1. Using installer

Download nvm-setup.zip and unzip the file and install it, keeping the configurations default.

1. Use curl Copy the below command and run it in your terminal

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash

After this reopen/open terminal and check the nvm version runing below command.

nvm -v

And that's it.

Mustkeem K
  • 8,158
  • 2
  • 32
  • 43
2

If someone is looking for install on Window 11! Not directly relevant here, but might be useful.

It is immaterial if you install NVM (version 1.1.9.) say after the node (16.15.1) is already installed. During the nvm installation process, it asks for the right to manage the existing node version and symlinks that.

Get the version from the GitHub repo, I opted for the zip version.

https://github.com/coreybutler/nvm-windows/releases

Double click the application and it is just a few steps.

vimal krishna
  • 2,886
  • 28
  • 22
  • I tried this on windows 10 and it worked once I took the right zip file to download from the latest releases. For anyone doing this I got confused as this is not the same as the main github software download (which I tried at first and had only a .bat file in). If you have anything other than "nvp-setup.exe" in the zip, then you have probably downloaded the wrong thing for windows install. This is easier than all the articles on how to do this which are pre 2022 and imply it is a big job. It isnt. run that exe and follow vimals instructions and its done. easy. – mdkb Jul 09 '22 at 02:24
1
1.downlad nvm 
2.install chocolatey
3.change C:\Program Files\node   to C:\Program Files\nodejsx

emphasized textThe first thing that we need to do is install NVM. website : https://learn.microsoft.com/en-us/windows/nodejs/setup-on-windows

Andre Cytryn
  • 2,506
  • 4
  • 28
  • 43
Fahimeh Ahmadi
  • 813
  • 8
  • 13
1

So this answer is for windows users that are using git bash or some other console emulator like cmder ... if you're using CMD this solution will not work for you also why? why are you still using CMD?

I know this is a pretty old post but I just achieved this yesterday and wanted to add my answer for anyone looking to do the same.

  • First check if you have .bashrc profile in your home directory by typing ls -alh ~ (by default this doesn't exist)
  • if it doesn't exist type this command to generate a .bashrc profile with default values in it cat /etc/bash.bashrc > ~/.bashrc (if it does exist skip this step)
  • Download and run the nvm install script as provided in the nvm docs page curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash (make sure you do this in your home directory)
  • then edit the new generated .bashrc profile file you created above; use nano/vim to do that nano ~/.bashrc and add the following to the bottom of the file export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm and save your .bashrc file with the changes.
  • lastly source your .bashrc file by typing source ~/.bashrc
  • verify installation nvm --version

and now you have nvm installed and you can use the commands as per https://github.com/nvm-sh/nvm#usage

Neenus
  • 134
  • 3
  • 12
  • I'm using Cmder on Windows. Sadly the above does not work. I have a .bashrc file with the export command inside. Running `source ~/.bashrc` in the prompt directly results in the error "source is not a known command...". I tried adding this command in a .sh file in the cmder config/profile.d directory and that did nothing. Also tried adding the export command in a .sh file in the same dir - again it did nothing. Running `nvm -v` results in "nvm is not a known command..." Any ideas? I can use nvm in bash, I just hate using bash – danwellman Mar 14 '23 at 10:42
  • 1
    @danwellman that is strange because `source` is a built in shell command and cmder should recognize it! either way if that is not working you can simply close your terminal and reopen again if nvm is still not working I would check `.bashrc` if it actually has the path to your nvm installation – Neenus Mar 16 '23 at 12:58
0

First off, I use nvm on linux machine.

When looking at the documentation for nvm at https://www.npmjs.org/package/nvm, it recommendations that you install nvm globally using the -g switch.

npm install -g nvm

Also there is a . in the path variable that they recommend.

export PATH=./node_modules/.bin:$PATH

so maybe your path should be

C:\Program Files (x86)\nodejs\node_modules\npm\\.bin
loganfsmyth
  • 156,129
  • 30
  • 331
  • 251
user3834928
  • 131
  • 1
  • 7
  • the g switch seemed to make things work on my Windows 7 machine, thanks – Alexander Mills Sep 04 '14 at 17:23
  • 1
    i set path as u say but when i try to `nvm install 6.9.1` this error occurs **Could not retrieve https://nodejs.org/dist/latest/SHASUMS256.txt. Get https://nodejs.org/dist/latest/SHASUMS256.txt: dial tcp** 104.20.22.46:443: i/o timeout – Kishan Oza May 10 '17 at 08:52
  • 4
    " npm install -g nvm " is not the correct way to install nvm – Ethan Mar 03 '20 at 15:42
0

An alternative to nvm-windows, which is mentioned in other answers would be Nodist.

I've had some issues with nvm-windows and admin privileges, which Nodist doesn't seem to have.

David Dostal
  • 711
  • 13
  • 17
0

I know I'm late here but this may help in the future if someone looking for NVM to install in Windows or linux
run this command in cmd

       $ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
vibhu
  • 369
  • 3
  • 10
  • This worked. After installing, use git bash and run these commands. `export NVM_DIR="$HOME/.nvm"` `[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" ` # This loads nvm – gsb22 Oct 04 '21 at 11:46