虚拟机Node.js-建议所有用户安装 [英] NVM & Node.js - Recommended install for all users
问题描述
是否建议为nvm安装,以便所有用户都可以使用它?我在网上找不到与此相关的任何内容.
is there a recommended install for nvm so all users can use it? i cannot find anything on the web regarding this.
这就是我所做的
- 将nvm安装在公共目录中
- 为所有用户在.profile中放置nvm.sh脚本位置
- 创建了一个nvm/alias目录(如果其他用户不在这里,nvm会抱怨)
然后,每个用户都必须运行"nvm use"或默认情况下将其放入其个人资料中
then each user must either run "nvm use " or put it in their profile by default
不确定是否有更好的方法?
not sure if there is a better way?
谢谢
推荐答案
这就是我所做的:
-
以root用户身份将
nvm
安装在/opt/nvm
中.好像是合适的位置.
Installed
nvm
in/opt/nvm
as root. Seemed like an appropriate location.
# git clone git@github.com:creationix/nvm.git /opt/nvm
创建目录/usr/local/nvm
.这是下载的地方($NVM_DIR
)
Created the directory /usr/local/nvm
. This is where the downloads will go ($NVM_DIR
)
# mkdir /usr/local/nvm
创建目录/usr/local/node
.这是NPM全局工作的去向:
Create the directory /usr/local/node
. This is where the NPM global stuff will go:
# mkdir /usr/local/node
在/etc/profile.d
中创建了一个名为nvm.sh
的文件,其内容如下:
Created a file called nvm.sh
in /etc/profile.d
with the following contents:
export NVM_DIR=/usr/local/nvm
source /opt/nvm/nvm.sh
export NPM_CONFIG_PREFIX=/usr/local/node
export PATH="/usr/local/node/bin:$PATH"
重新登录到Shell会话,然后设置默认节点版本.
Re-login to a shell session, then set the default node version.
# nvm install 0.10
# nvm alias default 0.10
现在,下次登录Shell会话时,所有用户的节点二进制文件都应位于PATH
中. NPM会将全局内容安装到/usr/local/node
前缀.
The node binaries should now be in the PATH
for all users the next time you login to a shell session. NPM will install global things to the /usr/local/node
prefix.
这篇关于虚拟机Node.js-建议所有用户安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!