Global npm packages are install on different user directory

1.1k Views Asked by At

Recently I have created a new user on Windows 10 and removed the old user, after that when I try adding an global npm package it get installed on the previous user %appdata%/Roaming directory. I'm not able to use those global libs now.

Say for example

npm install -g gulp

installs the gulp module under

C:\Users<DELETED_USER>\AppData\Roaming\npm\gulp

and not found in the new user directory

C:\Users<NEW_USER>\AppData\Roaming\npm\gulp

Is there any npm config I have to touch to fix this issue?

1

There are 1 best solutions below

0
On BEST ANSWER

When you run the following command:

npm config get prefix

it probably prints:

C:\Users\<DELETED_USER>\AppData\Roaming\npm\

If that's the case, i.e. it references the pathname to the <DELETED_USER>, then consider utilizing the npm config command to change the prefix value. E.g.

npm config set prefix "C:\Users\<NEW_USER>\AppData\Roaming\npm"

If you also run the following command:

run npm config ls -l

you may find other configuration properties (e.g. cache) whose values contain the <DELETED_USER> pathname in them too. For those also consider setting them as necessary using: npm config set <key> <value>