立诚勿怠,格物致知
It's all about connecting the dots

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

I use Mac. I installed node, and then one day I use nvm. Everything is well when I am using IntelliJ IDEA. But when I use VS Code, I will see the following tips in terminal panel. And I need to execute command `nvm use v16.14.2` to toggle to the expected node version.

nvm is not compatible with the npm config “prefix” option: currently set to “/usr/local” Run npm config delete prefix or nvm use --delete-prefix v9.2.1 to unset it.

How to fix it?

1. Delete npm prefix

npm config delete prefix
npm config set prefix $NVM_DIR/current

2. Delete node, node_modules, globally installed packages (not installed by nvm)

sudo rm -rf /usr/local/lib/node_modules

sudo rm /usr/local/bin/node

cd /usr/local/bin && ls -l | grep "../lib/node_modules/" | awk '{print $9}'| xargs rm

3. Set nvm

nvm alias default v16.14.2

nvm use v16.14.2

4. Validate

Close the current terminal panel and open a new one, then execute the follow command:

node -v

If the output is `v16.14.2`, then we succeed.

赞(1) 打赏
文章名称:《nvm is not compatible with the npm config "prefix" option》
文章链接:https://www.orzzone.com/nvm-is-not-compatible-with-the-npm-config-prefix-option.html
商业联系:yakima.public@gmail.com

本站大部分文章为原创或编译而来,对于本站版权文章,未经许可不得用于商业目的,非商业性转载请以链接形式标注原文出处。
本站内容仅供个人学习交流,不做为任何投资、建议的参考依据,因此产生的问题需自行承担。

评论 抢沙发

觉得文章有用就打赏一下文章作者

非常感谢你的打赏,我们将继续给力提供更多优质内容!

支付宝扫一扫打赏

微信扫一扫打赏

登录

找回密码

注册