Reputation: 9202
I have already followed node-and-npm-in-30-seconds.sh.
Earlier I used to create AngularJS application using Yeoman and bower with NodeJS. That time I used sudo to install all.
This is what I followed
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
Recently I tried to create an AngularJS application, but it didn't create properly. Then I found I should not use sudo while installing nodejs, yeoman and Bower.
I searched and found the solution here node-and-npm-in-30-seconds.sh.
So first I uninstalled the NodeJS
sudo apt-get remove nodejs
Then followed the first option provided in the 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
The last command didn't work. It showed
$ 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
I googled and tried the following from this SO answer
curl -O -L https://npmjs.org/install.sh
sh install.sh
It is showing the following error
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
Why is it so? And how can I resolve it? Thanks.
Upvotes: 12
Views: 18184
Reputation: 95
Easier option is available here
https://github.com/nodejs/help/wiki/Installation
Tip - For older vesion of OS, use older installation package.
Upvotes: 0
Reputation: 9202
Ok this I have tried and worked for me
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
Upvotes: 14