简体   繁体   中英

Npm packages are installed in the wrong node version folder of nvm

I have installed node 10.14.2 & node 12.13.1 with nvm (Node version manage)

Default version set to node 12.13.1

This it the output when I run nvm list

       v10.14.2
->     v12.13.1
         system
default -> 12 (-> v12.13.1)
node -> stable (-> v12.13.1) (default)
stable -> 12.13 (-> v12.13.1) (default)
iojs -> N/A (default)
unstable -> N/A (default)
lts/* -> lts/erbium (-> v12.13.1)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.16.2 (-> N/A)
lts/dubnium -> v10.17.0 (-> N/A)
lts/erbium -> v12.13.1

Now when I install a global npm package, it is installed in the v.10.14.2 folder instead of the v.12.13.1 one, why does it still refer to the old version folder??

In my .bash_profile file I have this if it can help

export NVM_DIR="$HOME/.nvm"
source ~/.nvm/nvm.sh

I had the same problem. I noticed i had a file ~/.npmrc which had one line in it...

prefix=/Users/spoogaloo/.nvm/versions/node/v12.16.1

This was the folder all my global node modules were being installed into, whichever version of node i had selected using nvm.

I deleted this file, opened a new terminal and the problem was fixed – new global node modules were installing into their correct folders, according to nvm's current node version.

I think it's because i had previously installed node using homebrew, and hadn't uninstalled it properly before installing nvm .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM