立诚勿怠,格物致知
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.

赞(0) 打赏
版权声明:非商业用途转载请注明文章链接,商业用途转载请联系邮箱获取授权。
文章名称:《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
本站内容仅供个人学习交流,不做为任何投资、建议的参考依据,因此产生的问题需自行承担。

评论 抢沙发

大前端WordPress主题 更专业 更方便

支持快讯、专题、百度收录推送、人机验证、多级分类筛选器,适用于垂直站点、科技博客、个人站,扁平化设计、简洁白色、超多功能配置、会员中心、直达链接、文章图片弹窗、自动缩略图等...

去看看

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

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

支付宝扫一扫打赏

微信扫一扫打赏

登录

找回密码

注册