Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

npm install yarn -g 全局下载时,下载路径下载到了安装目录下。没有下载到对应版本的安装目录下 #35

Closed
stormwyrmx opened this issue Dec 12, 2023 · 4 comments

Comments

@stormwyrmx
Copy link

屏幕截图 2023-12-12 220400
我选择的node版本是21.4.0,当我执行命令npm install yarn -g时,它安装到了nodejs目录下,没有安装到21.4.0目录下
error
输入 yarn -v ,命令行显示 nvm-desktop: command not found: yarn

@1111mp
Copy link
Owner

1111mp commented Dec 12, 2023

你终端输入npm root -g 看看npm全局安装包的路径是什么 或者npm config get prefix

@stormwyrmx
Copy link
Author

npm config get prefix的结果是D:\dev\nodejs。如果npm config set prefix D:\dev\nodejs\21.0.4,那么在使用别的版本,例如16.14.0时,npm config get prefix的结果也是D:\dev\nodejs\21.0.4

@1111mp
Copy link
Owner

1111mp commented Dec 12, 2023

这是正常的,这是npm的默认行为,具体可查看#23

npm的config保存在系统的.npmrc文件中,不管怎么切换版本,它们会共用这个文件(具体你可以查看npm的文档),所以如果你需要版本之间隔离的话,将.npmrc文件中的prefix选项删除即可,这样就会安装到各自版本node的路径内,即相互隔离。

@stormwyrmx
Copy link
Author

谢谢,照着#23加了环境变量D:\dev\nodejs到C:\Users\24431.nvmd\bin前面后就可以了。感谢作者!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants