【发布时间】:2016-07-02 23:05:16
【问题描述】:
所以我试图在 vagrant 中安装 nvm 和节点,但似乎无法使其工作。
显然,我无法让它加载/读取 nvm,因为 nvm 要求您重新加载终端。 ~/.profile 似乎没有做这项工作
使用ubuntu/xenial64
这是我的 bootstrap.sh 文件
#install nvm
cd ~
curl -sL https://raw.githubusercontent.com/creationix/nvm/v0.31.2/install.sh -o install_nvm.sh
bash install_nvm.sh
#this command makes it so that you don't need to re-open the terminal for 'nvm' to be available
source ~/.profile
#use nvm to install node
nvm install 6.2.2
nvm use 6.2.2
我得到的错误(稍作修改以隐藏个人信息):
==> default: Checking for guest additions in VM...
==> default: Mounting shared folders...
default: /installation_data => C:/work/<PATH_OMMITED>
==> default: Running provisioner: shell...
default: Running: C:/Users/ahmed/AppData/Local/Temp/vagrant-shell20160703-8248-1c82peg.sh
==> default: => Downloading nvm from git to '/home/ubuntu/.nvm'
=> default:
==> default: Cloning into '/home/ubuntu/.nvm'...
==> default: * (HEAD detached at v0.31.2)
==> default: master
==> default: => Appending source string to /home/ubuntu/.bashrc
==> default: => Close and reopen your terminal to start using nvm
==> default: /tmp/vagrant-shell: line 11: nvm: command not found
==> default: /tmp/vagrant-shell: line 12: nvm: command not found
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.
【问题讨论】:
-
您不能从脚本中
source ~/.profile,因为它仅适用于该脚本,而不适用于您运行 bootstrap.sh 的 shell。source bootstrap.sh会给你想要的结果吗?