0

I have been working an hour for this.

Taken from their official documentation :

curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs

However, its never working for me. I have tried to clear the npm cache, even uninstall it and run both command again. Its still not working. I keep getting version 0.10.25

I run :

grep -h ^deb /etc/apt/sources.list /etc/apt/sources.list.d/* 

And this is what i get :

deb http://id.archive.ubuntu.com/ubuntu/ trusty main restricted
deb-src http://id.archive.ubuntu.com/ubuntu/ trusty main restricted
deb http://id.archive.ubuntu.com/ubuntu/ trusty-updates main restricted
deb-src http://id.archive.ubuntu.com/ubuntu/ trusty-updates main restricted
deb http://id.archive.ubuntu.com/ubuntu/ trusty universe
deb-src http://id.archive.ubuntu.com/ubuntu/ trusty universe
deb http://id.archive.ubuntu.com/ubuntu/ trusty-updates universe
deb-src http://id.archive.ubuntu.com/ubuntu/ trusty-updates universe
deb http://id.archive.ubuntu.com/ubuntu/ trusty multiverse
deb-src http://id.archive.ubuntu.com/ubuntu/ trusty multiverse
deb http://id.archive.ubuntu.com/ubuntu/ trusty-updates multiverse
deb-src http://id.archive.ubuntu.com/ubuntu/ trusty-updates multiverse
deb http://id.archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://id.archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu trusty-security main restricted
deb-src http://security.ubuntu.com/ubuntu trusty-security main restricted
deb http://security.ubuntu.com/ubuntu trusty-security universe
deb-src http://security.ubuntu.com/ubuntu trusty-security universe
deb http://security.ubuntu.com/ubuntu trusty-security multiverse
deb-src http://security.ubuntu.com/ubuntu trusty-security multiverse
deb http://extras.ubuntu.com/ubuntu trusty main
deb-src http://extras.ubuntu.com/ubuntu trusty main
deb http://ppa.launchpad.net/cpug-devs/ppa/ubuntu saucy main
deb http://ppa.launchpad.net/cwchien/gradle/ubuntu saucy main
deb http://ppa.launchpad.net/dominik-stadler/subversion-1.7/ubuntu trusty main
deb http://ppa.launchpad.net/dominik-stadler/subversion-1.7/ubuntu trusty main
deb http://ppa.launchpad.net/dominik-stadler/subversion-1.8/ubuntu trusty main
deb http://linux.dropbox.com/ubuntu saucy main
deb http://dl.google.com/linux/chrome/deb/ stable main
deb http://dl.google.com/linux/chrome/deb/ stable main
deb http://dl.google.com/linux/chrome/deb/ stable main
deb http://ppa.launchpad.net/plushuang-tw/uget-stable/ubuntu saucy main
deb [arch=amd64,i386] http://repo.steampowered.com/steam/ precise steam
deb-src [arch=amd64,i386] http://repo.steampowered.com/steam/ precise steam
deb [arch=amd64,i386] http://repo.steampowered.com/steam/ precise steam
deb-src [arch=amd64,i386] http://repo.steampowered.com/steam/ precise steam
deb http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu trusty main
deb http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu trusty main
deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main
deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main

It seems the nodejs is not on the list.

What should i do? Please kindly help me

0

2 Answers 2

0

Below are the steps to install Node.js from source (OSX/linux)

NOTE - this installs Node.js which gives you both node as well as npm, they come together per release.

to start fresh remove prior node and npm installs as well as these :

sudo mv ~/.npmrc ~/.npmrc_ignore
sudo mv ~/.npm   ~/.npm_ignore
sudo mv ~/tmp    ~/tmp_ignore
sudo mv ~/.npm-init.js ~/.npm-init.js_ignore

download source from : http://nodejs.org/download/

cd node-v5.0.0   #  <-- or whatever download expands to

You may/should issue all following cmds as yourself NOT root (sudo)

Pick one of these NODE_PARENT locations to define where node gets installed into :

# export NODE_PARENT=/some/desired/install/path_goes_here
# export NODE_PARENT=/usr/local/bin/nodejs  # use this ONLY if you MUST install as root (sudo)
export NODE_PARENT=${HOME}/node-v5.0.0      # Recommended - owned by you NOT root

export PATH=${NODE_PARENT}/bin:${PATH} # jack up PATH for executables
export NODE_PATH=${NODE_PARENT}/lib/node_modules # so node itself can find its modules dir

./configure --prefix=${NODE_PARENT}

make
make install

which puts it into dir defined by above --prefix

when you use syntax : npm install -g some_cool_module the -g for global installs it into dir $NODE_PATH and not your $PWD

IMPORTANT - put above three export xxx=yyy commands into your ~/.bashrc or some such to persist these environment variable changes

On subsequent updates to Nodejs, just update your ~/.bashrc with new release name in your NODE_PARENT env var , then source this ~/.bashrc and simply issue the configure/make/install as above

If you had a prior install of node you may want to copy over previously installed modules into new location :

~/node-v5.0.0/lib/node_modules/

or do fresh module installs using npm install -g xxxx

0

I finally used the unofficial/outdated way :

sudo npm cache clean -f
sudo npm install -g n
sudo n stable

sudo ln -sf /usr/local/n/versions/node/<VERSION>/bin/node /usr/bin/node

Taken from :

How can I update my nodeJS to the latest version?

However this make my node -v and my nodejs -v have different version. The nodejs -v still return outdated version. I dont know if this have any effect yet.

Not the answer you're looking for? Browse other questions tagged .