nvm is not compatible with the npm config “prefix” option:

前端 未结 16 1443
梦毁少年i
梦毁少年i 2020-12-07 06:47

I am trying to run another NodeJS version with nvm but getting this error:

$ nvm use v4.2.4

nvm is not compatible with the npm config \"prefix\         


        
16条回答
  •  臣服心动
    2020-12-07 07:41

    I solved this problem when it was showing on VSCode and JetBrains Terminals, but not in the native terminal using the following commands:

    ls -la /usr/local/bin | grep "np[mx]"
    

    This will give you the resolved path at the end:

    ... npm -> ../lib/node_modules/npm/bin/npm-cli.js
    ... npx -> ../lib/node_modules/npm/bin/npx-cli.js
    

    From there, removing the files and relaunching VS Code should fix the issue:

    rm -R /usr/local/bin/npm /usr/local/lib/node_modules/npm/bin/npm-cli.js
    rm -R /usr/local/bin/npx /usr/local/lib/node_modules/npm/bin/npx-cli.js
    

    fix link: https://github.com/nvm-sh/nvm/issues/1690#issuecomment-392014774

提交回复
热议问题