Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
like image 432
Simone Pizzamiglio Avatar asked Dec 02 '25 03:12

Simone Pizzamiglio


1 Answers

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.

like image 151
chichilatte Avatar answered Dec 04 '25 21:12

chichilatte