节点在 vagrant 上配置期间安装,但在连接到 ssh 时消失 [英] Node is installed during provisioning on vagrant but disappears upon connecting to ssh

查看:28
本文介绍了节点在 vagrant 上配置期间安装,但在连接到 ssh 时消失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我真的对此感到厌烦,我不知道出了什么问题.我正在使用 Vagrant 1.7.2Ubuntu 13.04Virtual Box 4.3 12 r93733

I am really getting sick of this and I don't know what is wrong. I am using Vagrant 1.7.2 , Ubuntu 13.04 , Virtual Box 4.3 12 r93733

我的主机是 Windows 8.1

这是我在 bootstrap.sh 上找到的节点引导脚本

Here is my node bootstrap script found on my bootstrap.sh

echo "--- Installing Node.js ---"
curl https://raw.githubusercontent.com/creationix/nvm/v0.16.1/install.sh | bash
source ~/.nvm/nvm.sh
nvm install 0.12
nvm use 0.12
sudo cp ~/.nvm/versions/nodejs/v0.12/bin/node /bin/node

echo "--- Install node app dependencies --"
cd /var/www/html/node
npm install express
npm install youtube-audio-stream

在配置期间,我可以看到节点已正确安装.我可以看到 Now using node v0.12 .我还可以看到 npm install 成功

During provisioning I could see that node is installed correctly . I could see the Now using node v0.12 . I could also see that the npm install's are successful

但是,当我使用 vagrant ssh 连接时.我得到 No command 'nvm' found .程序节点"可以在以下包中找到:.我还检查了 ~/.nvm/ 目录,它不存在.

However when I connect using vagrant ssh . I get No command 'nvm' found . And The program 'node' can be found in the following packages: . I also checked ~/.nvm/ directory, it is not existing.

它变得更奇怪了.所以当我在 ssh 时,我再次重新运行脚本.然后 nvm 现在已正确安装,我可以使用 node.js 了.

It becomes even weirder. So while I'm at ssh, I rerun the script again. Then nvm is now correctly installed and I could use node.

推荐答案

这是我想到的

echo "--- Installing Node.js ---"
git clone https://github.com/creationix/nvm.git /home/vagrant/.nvm && cd /home/vagrant/.nvm && git checkout `git describe --abbrev=0 --tags`
source /home/vagrant/.nvm/nvm.sh
nvm install 0.12
nvm use 0.12
n=$(which node);n=${n%/bin/node}; chmod -R 755 $n/bin/*; sudo cp -r $n/{bin,lib,share} /usr/local

这篇关于节点在 vagrant 上配置期间安装,但在连接到 ssh 时消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆