Search code examples
node.jsnpmnvm

npm path and package path is not the same


I use nvm to manage node version.

I am using node version 10.15

> which npm
/Users/yizhuowang/.nvm/versions/node/v10.15.0/bin/npm

However, npm installed global package for version v8.9.0

> npm list -g --depth 0
/Users/yizhuowang/.nvm/versions/node/v8.9.0/lib

I cannot find any special configuration .bashrc or .zshrc. I use Zsh if this is something related.


Solution

  • It's because I have set npm prefix.

    npm config delete prefix fixed this issue.

    > npm config get prefix
    /Users/yizhuowang/.nvm/versions/node/v8.9.0
    > npm config delete prefix
    > npm config get prefix
    /Users/yizhuowang/.nvm/versions/node/v10.13.0
    > npm list -g --depth=0
    /Users/yizhuowang/.nvm/versions/node/v10.13.0/lib
    └── [email protected]