2016-07-02 9 views
1

Also versuche ich nvm und node in vagrant zu installieren, aber es scheint nicht zu funktionieren. Offenbar habe ich Probleme, es zu laden/lesen nvm, da nvm erfordert, dass Sie Ihr Terminal neu laden. ~/.profile scheint nicht ubuntu/xenial64vagrant bootstrap: source ~/.profile funktioniert nicht

#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 

der Fehler, den Job

mit zu I (leicht modifizierte Daten zu verstecken) bekommen Dies ist meine bootstrap.sh Datei:

==> 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. 
+0

Sie können ~/.profile nicht aus einem Skript beziehen, da es nur für dieses Skript gilt und nicht für die Shell, von der Sie bootstrap.sh ausgeführt haben. Liefert 'source bootstrap.sh' das gewünschte Ergebnis? –

Antwort

3

Anstatt ~/.profile zu suchen, versuchen Sie dies:

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 6.2.2 
nvm use 6.2.2 
n=$(which node);n=${n%/bin/node}; chmod -R 755 $n/bin/*; sudo cp -r $n/{bin,lib,share} /usr/local 
echo $n 

Bitte beziehen Sie sich auf this Post. Getestet auf Scotch Box. Scheint einfach gut zu funktionieren.