25

I am trying to update my local node version from 8.9.0 to 8.10.0 using nvm. But it's not getting reflected. Here's what I tried:

node -v

-> v8.9.0

nvm use 8.10.0

-> Now using node v8.10.0 (npm v5.5.1)

node -v

-> v8.9.0

I am unable to get why it won't change. Please let me know what have I done wrong.

psr
  • 2,619
  • 4
  • 32
  • 57
  • 7
    You might have Node installed in multiple paths, with `nvm` only managing one. What does `which -a node` tell you? – Jonathan Lonowski Oct 06 '18 at 06:34
  • It says `/usr/local/bin/node`, `/Users/prabhjotrai/.nvm/versions/node/v8.10.0/bin/node`, `/usr/local/bin/node` ``` – psr Oct 06 '18 at 07:02
  • I see there are multiple paths, what fix would you suggest? – psr Oct 06 '18 at 07:05
  • 11
    Have you installed Node via Homebrew as well? If so, [`brew uninstall node`](https://stackoverflow.com/a/26919540) would uninstall the instance at `/usr/local/bin/node`, leaving the other managed by nvm. Otherwise, you can try to [modify your `PATH` variable](https://stackoverflow.com/questions/7703041) (or any shell configs which may alter it before opening) to give the nvm path priority. – Jonathan Lonowski Oct 06 '18 at 07:38
  • 1
    nvm maintainer here - the issue is likely that your PATH isn't set up properly in your shell profile file. the easiest solution is to move the nvm sourcing lines to the end of it. If that still doesn't work, please file an issue on the github repo. – LJHarb Mar 06 '21 at 20:40

5 Answers5

15

Adding few notes about my experience on debugging this problem.

First, I started out with the command provided by Jonathan which -a node and got the same output as op:

/usr/local/bin/node
/Users/<my-user>/.nvm/versions/node/v8.10.0/bin/node

Moving on to the next comment by Jonathan: Have you installed Node via Homebrew as well?, I tried uninstalling node by brew uninstall node and got and error that said it could not uninstall node as there was another program dependent on it. yarn.

And then realised that brew had installed its own version of node because I installed yarn through brew, which was overwriting the node version that I wanted to use through nvm.

Uninstalling brew's version of yarn+node fixed my problem. I still needed yarn, and now I have to install yarn globally for each node version managed by nvm.

Inconvenient, I agree. But so is maintaining twenty thousand versions of node for each project so not very different in my opinion.

All of this was done on M1 MacOS and your output might vary based on your system.

darth-coder
  • 670
  • 8
  • 20
  • 7
    You could also try `brew uninstall --ignore-dependencies node` – FooBar Sep 15 '21 at 16:33
  • 4
    In my case, I just needed to `brew uninstall node` (and let nvm manage it). – Shaun Saker Jul 29 '22 at 10:53
  • In my case doing `brew uninstall node` led to an error ("no such keg...") because I installed node with a specific version so I had to do `brew uninstall node@18` – Prusdrum Aug 17 '23 at 10:26
2

Please ensure that when you input arch on command prompt, then output is i386.

This is achieved using Rosetta.

Following sequence of commands on terminal worked: -

nvm install 8.10.0
nvm install --lts
nvm ls
brew upgrade
arch -arm64 brew install n
n

Now select node version 8.10.0 using up or down arrow keys in keyboard and then quit from command prompt using command+q

Please do not try brew uninstall --ignore-dependencies node

S Satyen
  • 31
  • 3
0

Just check you environment variables first. It might be mapping to node@8.9.0. You need to remove the environment variable first.

Neeraj Kumar
  • 6,045
  • 2
  • 31
  • 23
0

If you are also using volta. Volta may take precedence.

Use which -a node to verify.

If that is the case, use volta pin node@version to switch.

Devs love ZenUML
  • 11,344
  • 8
  • 53
  • 67
-2

First check your nvm version installed on your local system. go to command prompt and type "nvm list" If you don't see the versions 8.10.0 in the list then install using command : "nvm install 8.10.0" and then try "nvm use 8.10.0".

For reference : http://www.tutorial-points.com/2018/11/nvm-installation-on-windows.html