Nvm: Switching node versions does not change the global install directoy

Created on 15 Aug 2016  路  9Comments  路  Source: nvm-sh/nvm

Bash/OSX

Any time I install a global module, it gets put in /Users/<username>/.nvm/versions/node/v4.4.5/

Mac OS

Most helpful comment

I had a bit of a mess with my different versions of nodes, despite the fact that I was using nvm to manage my node versions. I also had brew so I had to leave everything clear.
The real problem is that your system might be reading node from: /usr/local/bin/node

Brew end up helping me to solve the problem

  1. brew link node Set's your system with the latest version you have in brew.
  2. If the previous command didn't link your brew version with the system one. Then force it via:
    brew link --overwrite node

I also set up my nvm just to be consistent and use the same version of node everywhere.
I ran nvm debug then have a look at the line nvm current: system in my case it had system so I had to ran the following command to update my system's node version:
nvm install node --reinstall-packages-from=node

All 9 comments

What does nvm --version print out, and nvm debug?

Do you have NODE_PATH or npm config get prefix set anywhere?

nvm --version
0.31.4

No specific NODE_PATH or npm config get prefix set.

And nvm debug? What does nvm ls print out?

nvm debug

USF4C89A80095:ember-cli-flowtype rtorruellas$ nvm debug
nvm --version: v0.31.4
$SHELL: /bin/bash
$HOME: /Users/rtorruellas
$NVM_DIR: '$HOME/.nvm'
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
nvm current: v6.3.1
which node: $NVM_DIR/versions/node/v6.3.1/bin/node
which iojs: 
which npm: $NVM_DIR/versions/node/v6.3.1/bin/npm
npm config get prefix: $NVM_DIR/versions/node/v4.4.5
npm root -g: $NVM_DIR/versions/node/v4.4.5/lib/nod
nvm ls
         v4.4.5  
->       v6.3.1  
default -> 6.3.1 (-> v6.3.1)
node -> stable (-> v6.3.1) (default)
stable -> 6.3 (-> v6.3.1) (default)
iojs -> N/A (default)
lts/* -> lts/argon (-> N/A)
lts/argon -> v4.4.7 (-> N/A)

Thanks - you can see in the debug output that npm config get prefix and npm root -g is printing out the v4.4.5 version. Do you have an ~/.npmrc with "prefix" in it anywhere?

AKA rtorr learn to node. Thank you so much, npmrc is where the culprit is! 馃拑 (assuming if I remove that it will work)

Yes, that "prefix" line is the problem :-) Please follow up if that doesn't fix it!

I ran nvm debug then have a look at the line nvm current: system in my case it had system so I had to ran the following command to update my system's node version:
nvm install node --reinstall-packages-from=node

I had a bit of a mess with my different versions of nodes, despite the fact that I was using nvm to manage my node versions. I also had brew so I had to leave everything clear.
The real problem is that your system might be reading node from: /usr/local/bin/node

Brew end up helping me to solve the problem

  1. brew link node Set's your system with the latest version you have in brew.
  2. If the previous command didn't link your brew version with the system one. Then force it via:
    brew link --overwrite node

I also set up my nvm just to be consistent and use the same version of node everywhere.
I ran nvm debug then have a look at the line nvm current: system in my case it had system so I had to ran the following command to update my system's node version:
nvm install node --reinstall-packages-from=node

Was this page helpful?
0 / 5 - 0 ratings