node.js NVM 全局模块文件夹
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33817739/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
NVM global module folder
提问by Juriy
I am using NVM and I am trying to install global NPM modules. That action requires permissions to a folder that I don't have permissions to. With regular node.js/npm that was easy to solve with prefixconfiguration but NVM explicitly forbids it.
我正在使用 NVM 并且我正在尝试安装全局 NPM 模块。该操作需要对我无权访问的文件夹的权限。使用常规的 node.js/npm 很容易通过prefix配置解决,但 NVM 明确禁止它。
What is the right way to change the path to global modules folder in NVM?
在 NVM 中更改全局模块文件夹路径的正确方法是什么?
回答by M J
To see the location of the current version of node you are using:
要查看您正在使用的当前节点版本的位置:
nvm which current
You are using the system installation if .nvm is not in the path, similar to the following:
如果 .nvm 不在路径中,则您正在使用系统安装,类似于以下内容:
/usr/local/bin/node
To switch to a version managed by nvm:
要切换到由 nvm 管理的版本:
nvm use 4
To verify you are using a version managed by nvm:
要验证您使用的是由 nvm 管理的版本:
nvm which current
You should see something similar to the following:
您应该会看到类似于以下内容的内容:
/Users/<your-user-name>/.nvm/versions/node/v4.2.2/bin/node
You should only experience global install permission issues when you are using the system installation.
您应该只在使用系统安装时遇到全局安装权限问题。

