2015-06-24 18 views
5

Ich habe bereits node-and-npm-in-30-seconds.sh gefolgt.Installation von NodeJS ohne Sudo in Ubuntu

Früher habe ich AngularJS-Anwendung mit Yeoman und Bower mit NodeJS erstellt. Damals benutzte ich sudo, um alles zu installieren. Diese

ist das, was ich folgte

sudo apt-get install python-software-properties python g++ make 
sudo add-apt-repository ppa:chris-lea/node.js 
sudo apt-get update 
sudo apt-get install nodejs 

sudo apt-get install git-core 

Vor kurzem habe ich versucht, eine AngularJS Anwendung zu erstellen, aber es hat nicht richtig erstellen. Dann fand ich, dass ich Sudo nicht benutzen sollte, während ich nodejs, yeoman und Bower installiere.

Ich suchte und fand die Lösung hier node-and-npm-in-30-seconds.sh.

Also zuerst deinstalliert ich die NodeJS

sudo apt-get remove nodejs 

Dann folgte die erste Option in den darin enthaltenen Link

echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc 
. ~/.bashrc 
mkdir ~/local 
mkdir ~/node-latest-install 
cd ~/node-latest-install 
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1 
./configure --prefix=~/local 
make install # ok, fine, this step probably takes more than 30 seconds... 
curl https://www.npmjs.org/install.sh | sh 

Der letzte Befehl nicht funktioniert hat. Es zeigte

$ curl https://www.npmjs.org/install.sh | sh 
    % Total % Received % Xferd Average Speed Time Time  Time Current 
           Dload Upload Total Spent Left Speed 
100 51 100 51 0  0  63  0 --:--:-- --:--:-- --:--:-- 63 
sh: 1: Moved: not found 

ich gegoogelt und versucht, die folgenden von this SO answer

curl -O -L https://npmjs.org/install.sh 
sh install.sh 

Es wird die folgende Fehler zeigt

npm cannot be installed without node.js. 
Install node first, and then try again. 

Maybe node is installed, but not in the PATH? 
Note that running as sudo can change envs. 

PATH=/home/myuser/local/bin:/usr/lib/jvm/java-7-oracle/bin:/usr/lib/jvm/java-7-oracle/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games 

Warum ist es so? Und wie kann ich es lösen? Vielen Dank.

Antwort

6

Ok das habe ich versucht, und arbeitete für mich

echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc 
. ~/.bashrc 
mkdir ~/local 
mkdir ~/node-latest-install 
cd ~/node-latest-install 
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1 
./configure --prefix=$HOME/local 
make install 
curl -L https://www.npmjs.com/install.sh | sh