How can I update my nodeJS to the latest version?
I have installed nodeJS on Ubuntu with following code
sudo apt-get install nodejs
Since I am a new user for ubuntu I also ran this code too
sudo apt-get install npm
Now when I type
nodejs --version
It shows
v0.6.19
I checked and saw latest nodeJS version is 0.10.26
How can I update my version of nodeJS to 0.10.26
?
I tried with
sudo apt-get install <packagename>
sudo apt-get install --only-upgrade <packagename>
but no luck.
apt nodejs
add a comment |
I have installed nodeJS on Ubuntu with following code
sudo apt-get install nodejs
Since I am a new user for ubuntu I also ran this code too
sudo apt-get install npm
Now when I type
nodejs --version
It shows
v0.6.19
I checked and saw latest nodeJS version is 0.10.26
How can I update my version of nodeJS to 0.10.26
?
I tried with
sudo apt-get install <packagename>
sudo apt-get install --only-upgrade <packagename>
but no luck.
apt nodejs
1
It's better to use nvm to install nodejs. It stands for "Node Version Manager". You can very easily install multiple versions of nodejs, switch between them and set a default.
– Mina Michael
Nov 17 '18 at 16:11
add a comment |
I have installed nodeJS on Ubuntu with following code
sudo apt-get install nodejs
Since I am a new user for ubuntu I also ran this code too
sudo apt-get install npm
Now when I type
nodejs --version
It shows
v0.6.19
I checked and saw latest nodeJS version is 0.10.26
How can I update my version of nodeJS to 0.10.26
?
I tried with
sudo apt-get install <packagename>
sudo apt-get install --only-upgrade <packagename>
but no luck.
apt nodejs
I have installed nodeJS on Ubuntu with following code
sudo apt-get install nodejs
Since I am a new user for ubuntu I also ran this code too
sudo apt-get install npm
Now when I type
nodejs --version
It shows
v0.6.19
I checked and saw latest nodeJS version is 0.10.26
How can I update my version of nodeJS to 0.10.26
?
I tried with
sudo apt-get install <packagename>
sudo apt-get install --only-upgrade <packagename>
but no luck.
apt nodejs
apt nodejs
edited Jun 8 '14 at 23:28
Jorge Castro
37.1k106422617
37.1k106422617
asked Feb 26 '14 at 20:51
Kanishka PanamaldeniyaKanishka Panamaldeniya
2,888399
2,888399
1
It's better to use nvm to install nodejs. It stands for "Node Version Manager". You can very easily install multiple versions of nodejs, switch between them and set a default.
– Mina Michael
Nov 17 '18 at 16:11
add a comment |
1
It's better to use nvm to install nodejs. It stands for "Node Version Manager". You can very easily install multiple versions of nodejs, switch between them and set a default.
– Mina Michael
Nov 17 '18 at 16:11
1
1
It's better to use nvm to install nodejs. It stands for "Node Version Manager". You can very easily install multiple versions of nodejs, switch between them and set a default.
– Mina Michael
Nov 17 '18 at 16:11
It's better to use nvm to install nodejs. It stands for "Node Version Manager". You can very easily install multiple versions of nodejs, switch between them and set a default.
– Mina Michael
Nov 17 '18 at 16:11
add a comment |
12 Answers
12
active
oldest
votes
Use n module from npm in order to upgrade node
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
To upgrade to latest version (and not current stable) version, you can use
sudo n latest
To undo:
sudo apt-get install --reinstall nodejs-legacy # fix /usr/bin/node
sudo n rm 6.0.0 # replace number with version of Node that was installed
sudo npm uninstall -g n
Found in David Walsh blog
http://davidwalsh.name/upgrade-nodejs
10
this should be the correct answer.n
is a node helper package that installs or update a given node.js version.
– Martin
Oct 2 '14 at 12:38
37
I would advise strongly against doing this on a production instance. It can seriously mess stuff up with your global npm packages and your ability to install new ones.
– Loourr
Feb 19 '15 at 22:30
5
I tried this... now when I runnode
I get this errorbash: /usr/bin/node: No such file or directory
what should I do ?
– Yerko Palma
Oct 11 '15 at 0:44
7
but still nodejs --version sow 0.10.25
– Mansuu....
Dec 29 '16 at 19:30
9
David Walsh says use NVM instead
– Ads20000
Jan 12 '17 at 12:15
|
show 20 more comments
Complete installation instructions have since been uploaded here by Nodesource. It is copied below for your reference. Instructions are the same for updating to the latest version.
Node.js v10.x:
NOTE: If you are using Ubuntu Precise or Debian Wheezy, you might want to read about running Node.js >= 6.x on older distros
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_10.x | bash -
apt-get install -y nodejs
Node.js v9.x:
NOTE: If you are using Ubuntu Precise or Debian Wheezy, you might want to read about running Node.js >= 6.x on older distros
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_9.x | bash -
apt-get install -y nodejs
Node.js v8.x:
NOTE: If you are using Ubuntu Precise or Debian Wheezy, you might want to read about running Node.js >= 6.x on older distros
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_8.x | bash -
apt-get install -y nodejs
Node.js v7.x:
NOTE: Debian Wheezy and Ubuntu Precise packages are NOT available for this release. Please reference running Node.js >= 4.x on older distros
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_7.x | bash -
apt-get install -y nodejs
Node.js v6.x:
NOTE: If you are using Ubuntu Precise or Debian Wheezy, you might want to read about running Node.js >= 4.x on older distros.
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_6.x | bash -
apt-get install -y nodejs
Node.js v5.x:
NOTE: If you are using Ubuntu Precise or Debian Wheezy, you might want to read about running Node.js >= 4.x on older distros.
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_5.x | bash -
apt-get install -y nodejs
Node.js v4.x:
NOTE: If you are using Ubuntu Precise or Debian Wheezy, you might want to read about running Node.js >= 4.x on older distros.
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_4.x | bash -
apt-get install -y nodejs
Node.js v0.12:
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_0.12 | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_0.12 | bash -
apt-get install -y nodejs
Node.js v0.10:
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_0.10 | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_0.10 | bash -
apt-get install -y nodejs
io.js v3.x:
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_iojs_3.x | sudo -E bash -
sudo apt-get install -y iojs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_iojs_3.x | bash -
apt-get install -y iojs
io.js v2.x:
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_iojs_2.x | sudo -E bash -
sudo apt-get install -y iojs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_iojs_2.x | bash -
apt-get install -y iojs
io.js v1.x:
Note: this branch of io.js is not actively maintained and is not recommended for production use.
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_iojs_1.x | sudo -E bash -
sudo apt-get install -y iojs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_iojs_1.x | bash -
apt-get install -y iojs
I'd advise either removing the outdated information, or moving them to the bottom of the question, so that the current info is read first.
– k0pernikus
Dec 3 '15 at 16:05
@k0pernikus How's that? :p
– dayuloli
Dec 4 '15 at 2:44
Awesome :) I installed node4 yesterday after reading. It's outdated already ^^
– k0pernikus
Dec 4 '15 at 19:04
2
This is the answer that worked for me!
– eri0o
Mar 12 '16 at 4:16
For menode --version
still said "0.12.0". I had torm /usr/local/bin/node
, then I was able to use the newly installed version of nodejs.
– Ludachrispeed
Jul 17 '16 at 16:21
|
show 4 more comments
This PPA is out of date and not maintained anymore; you should consider other answers instead of this one.
You can install the latest version from PPA:
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs
12
I think this would be a better answer if you (also) provided a non-ppa way of doing this, ppas are notoriously known for becoming outdated and unmaintained, essentially making the answer useless.
– pzkpfw
Feb 27 '14 at 16:21
@bigbadonk420 yeah, if you just googled it, probably better to skip the first line and do just update and install-worked for me with node 0.10.34
– Capaj
Dec 22 '14 at 11:46
@Capaj nope. that didn't help...
– deostroll
Dec 24 '14 at 0:47
6
Don't recommend using this ppa any more, it seems to be rather out of date.
– Kzqai
Dec 2 '15 at 12:12
add a comment |
I use NVM to handle my Node versions. Very simple to set up and easy to use.
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
To install NVM globally instead, use the following curl command instead of the one above (and presumably don't use the second command but do use the third one)
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | NVM_DIR=/usr/local/nvm bash
Then use nvm install stable
(or insert a version number instead of stable
) to get the latest/a specific version of Node. Use nvm use stable
(or a specific version number) to use that Node version. Use nvm ls
to see what Node versions you have installed and nvm uninstall stable
(or a specific version number) to remove a specific version of Node.
Sources:
Install, usage
Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.
– Warren Hill
Mar 31 '14 at 14:30
Apologies for my noobness. Updated answer
– amnah
Mar 31 '14 at 16:27
the given curl path is not working. I used "curl raw.githubusercontent.com/creationix/nvm/v0.13.1/install.sh | bash" as given in the github.com/creationix/nvm
– Senthil
Aug 18 '14 at 3:35
Don't forget to update the url part to the latest version of nvm
– Nidhin David
Oct 21 '16 at 6:59
add a comment |
I also recommend using nvm instead, and also removing the already installed version to avoid conflicts in the terminal
sudo apt purge nodejs npm
then install nvm and use it
Video Explanation
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
to download and install nvm
nvm install node
should download and install the latest version of node.
To update node later on just do
nvm install node
nvm alias default node
2
This should be the only accepted answer - in case you want to have a sane and up to date Node setup in Ubuntu.
– José L. Patiño
Aug 20 '18 at 13:35
add a comment |
I tried the same list commands on my ubuntu 14.04 but it was still throwing an error.
Commands I executed were:
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs
and the error i was getting:
Invalid version 0.12.2
Line 299: curl not found in /bin/n
What I figured out was curl utility was not installed on my os.
I executed command:
apt-get install curl
(use sudo
as prefix if you are not su
)
and then repeated the steps suggest in answer and it work ;)
add a comment |
This one installs the latest node v0.12.* from nodesource.
sudo apt-get install -y curl
curl -sL https://deb.nodesource.com/setup_0.12 | sudo bash -
sudo apt-get install -y nodejs
For node v4.x
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs
2
Are you installing node from scratch? The question was about updating not installing
– Green
Feb 24 '17 at 5:56
add a comment |
I suggest you first remove all nodejs installs
then execute below script once you edit with desired nodejs version and its install parent directory
see all available nodejs versions
https://nodejs.org/dist/
below script will allow you to install any of those nodejs versions on linux or OSX
#!/bin/bash
# usage :
#
# edit two vars in below : NODE_VER and CODE_PARENT_DIR
#
# ... execute this script as yourself unless you choose a root owned value for var CODE_PARENT_DIR
# whichever id you execute this as determines the id you will issue npm commands as : npm install -g foo-bar
#
# NOTE - nodejs comes bundled with npm ... so no need to do separate npm install
# this scripts runs fine on linux or OSX
# ... copy all the lines starting here .. top of copy .... and ending ... end of copy ...
# and paste into your ~/.bashrc file so proper env vars get set
# ............... top of copy ........................ install_node.sh
# export NODE_VER=v7.2.0 # see available versions at https://nodejs.org/dist/
# export NODE_VER=v8.5.0 # edit this line next time you need to update nodejs
export NODE_VER=v9.3.0 # edit this line next time you need to update nodejs
# ... pick parent dir of nodejs install ... comment out or remove ONE of below
# export CODE_PARENT_DIR=/opt/code # root owned dir ... requires you to sudo prior to npm install going forward
export CODE_PARENT_DIR=${HOME} # RECOMMENDED execute as yourself including npm install
# ......... following env vars are OK no edits needed ... only ever need to edit above vars
curr_OS=$( uname )
echo curr_OS $curr_OS
if [[ "${curr_OS}" == "Darwin" ]]; then
OS_ARCH=darwin-x64
elif [[ "${curr_OS}" == "Linux" ]]; then
OS_ARCH=linux-x64
else
echo "ERROR - failed to recognize OS $curr_OS"
exit 5
fi
if [[ -z ${CODE_PARENT_DIR} ]]; then
echo "ERROR - failed to see env var CODE_PARENT_DIR"
exit 5
fi
export NODE_CODEDIR=${CODE_PARENT_DIR}/nodejs
export COMSUFFIX=tar.gz
export NODE_NAME=node-${NODE_VER}
export NODE_PARENT=${NODE_CODEDIR}/${NODE_NAME}-${OS_ARCH}
export PATH=${NODE_PARENT}/bin:${PATH}
export NODE_PATH=${NODE_PARENT}/lib/node_modules
# ............... end of copy ........................ install_node.sh
# copy and paste above from ... top of copy ... to here into your file ~/.bashrc
echo
echo "NODE_CODEDIR $NODE_CODEDIR<--"
echo
echo "mkdir -p ${NODE_CODEDIR}"
echo
mkdir -p ${NODE_CODEDIR}
echo
echo "cd ${NODE_CODEDIR}"
cd ${NODE_CODEDIR}
echo
# this is compiled code NOT source
[ -f ${NODE_NAME}-${OS_ARCH}.${COMSUFFIX} ] && rm ${NODE_NAME}-${OS_ARCH}.${COMSUFFIX} # if file exists remove
echo "wget -q --show-progress https://nodejs.org/download/release/${NODE_VER}/${NODE_NAME}-${OS_ARCH}.${COMSUFFIX}"
wget -q --show-progress https://nodejs.org/download/release/${NODE_VER}/${NODE_NAME}-${OS_ARCH}.${COMSUFFIX}
echo
echo "tar -C ${NODE_CODEDIR} -xf ${NODE_NAME}-${OS_ARCH}.${COMSUFFIX}"
tar -C ${NODE_CODEDIR} -xf ${NODE_NAME}-${OS_ARCH}.${COMSUFFIX}
echo
[ -f ${NODE_NAME}-${OS_ARCH}.${COMSUFFIX} ] && rm ${NODE_NAME}-${OS_ARCH}.${COMSUFFIX} # if file exists remove
# ........... done ........... #
which node
node --version
# .... bottom of file install_node.sh
add a comment |
If using n
does not work, you can install the latest version of nodejs
(i. e. version 8) running the following commands:
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
Further instructions are here.
add a comment |
NVM (Node Version manager) with --lts
NVM was mentioned at: https://askubuntu.com/a/441527/52975 but here goes a more complete usage example, including the sane --lts
version.
NVM installs both the latest stable node and npm for you
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | sh
source ~/.nvm/nvm.sh
nvm install --lts
nvm use --lts
npm --version
Now test it out with a dummy package:
npm install --global vaca
vaca
Since the sourcing has to be done for every new shell, you will probably want to add the following to your .bashrc
:
f="$HOME/.nvm/nvm.sh"
if [ -r "$f" ]; then
. "$f" &>'/dev/null'
nvm use --lts &>'/dev/null'
fi
Advantages:
allows you to use multiple versions of Node and without sudo
is analogous to Ruby RVM and Python Virtualenv, widely considered best practice in Ruby and Python communities
downloads a pre-compiled binary where possible, and if not it downloads the source and compiles one for you
We can easily switch node versions with:
nvm install 0.9.0
nvm install 0.9.9
nvm use 0.9.0
node --version
#v0.9.0
nvm use 0.9.9
node --version
#v0.9.9
You can then use a git tracked .nvmrc
file to indicate the node version required for a given project: https://stackoverflow.com/questions/24869959/how-do-i-specify-a-local-version-of-node-for-a-project/54503474#54503474
Tested in Ubuntu 17.10.
add a comment |
If you are behind a proxy, maybe you could get this error when you run 'sudo n stable':
Error: invalid version
You have to set the env variables like this:
export HTTP_PROXY=http://your-proxy-url:port
export HTTPS_PROXY=http://your-proxy-url:port
And then run the command passing these variables to the root user:
sudo -E n stable
Credits to: github.com/tj/n/issues/430
– luandrea
Jun 8 '18 at 13:50
add a comment |
Using nvm is preferred method. First install nvm:
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
Then install nodejs:
nvm install node
Now on, you can easy switch versions of node.
add a comment |
protected by Community♦ Jul 4 '17 at 21:42
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?
12 Answers
12
active
oldest
votes
12 Answers
12
active
oldest
votes
active
oldest
votes
active
oldest
votes
Use n module from npm in order to upgrade node
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
To upgrade to latest version (and not current stable) version, you can use
sudo n latest
To undo:
sudo apt-get install --reinstall nodejs-legacy # fix /usr/bin/node
sudo n rm 6.0.0 # replace number with version of Node that was installed
sudo npm uninstall -g n
Found in David Walsh blog
http://davidwalsh.name/upgrade-nodejs
10
this should be the correct answer.n
is a node helper package that installs or update a given node.js version.
– Martin
Oct 2 '14 at 12:38
37
I would advise strongly against doing this on a production instance. It can seriously mess stuff up with your global npm packages and your ability to install new ones.
– Loourr
Feb 19 '15 at 22:30
5
I tried this... now when I runnode
I get this errorbash: /usr/bin/node: No such file or directory
what should I do ?
– Yerko Palma
Oct 11 '15 at 0:44
7
but still nodejs --version sow 0.10.25
– Mansuu....
Dec 29 '16 at 19:30
9
David Walsh says use NVM instead
– Ads20000
Jan 12 '17 at 12:15
|
show 20 more comments
Use n module from npm in order to upgrade node
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
To upgrade to latest version (and not current stable) version, you can use
sudo n latest
To undo:
sudo apt-get install --reinstall nodejs-legacy # fix /usr/bin/node
sudo n rm 6.0.0 # replace number with version of Node that was installed
sudo npm uninstall -g n
Found in David Walsh blog
http://davidwalsh.name/upgrade-nodejs
10
this should be the correct answer.n
is a node helper package that installs or update a given node.js version.
– Martin
Oct 2 '14 at 12:38
37
I would advise strongly against doing this on a production instance. It can seriously mess stuff up with your global npm packages and your ability to install new ones.
– Loourr
Feb 19 '15 at 22:30
5
I tried this... now when I runnode
I get this errorbash: /usr/bin/node: No such file or directory
what should I do ?
– Yerko Palma
Oct 11 '15 at 0:44
7
but still nodejs --version sow 0.10.25
– Mansuu....
Dec 29 '16 at 19:30
9
David Walsh says use NVM instead
– Ads20000
Jan 12 '17 at 12:15
|
show 20 more comments
Use n module from npm in order to upgrade node
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
To upgrade to latest version (and not current stable) version, you can use
sudo n latest
To undo:
sudo apt-get install --reinstall nodejs-legacy # fix /usr/bin/node
sudo n rm 6.0.0 # replace number with version of Node that was installed
sudo npm uninstall -g n
Found in David Walsh blog
http://davidwalsh.name/upgrade-nodejs
Use n module from npm in order to upgrade node
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
To upgrade to latest version (and not current stable) version, you can use
sudo n latest
To undo:
sudo apt-get install --reinstall nodejs-legacy # fix /usr/bin/node
sudo n rm 6.0.0 # replace number with version of Node that was installed
sudo npm uninstall -g n
Found in David Walsh blog
http://davidwalsh.name/upgrade-nodejs
edited Mar 26 '18 at 23:26
Community♦
1
1
answered Jun 8 '14 at 23:14
eballesteeballeste
9,804187
9,804187
10
this should be the correct answer.n
is a node helper package that installs or update a given node.js version.
– Martin
Oct 2 '14 at 12:38
37
I would advise strongly against doing this on a production instance. It can seriously mess stuff up with your global npm packages and your ability to install new ones.
– Loourr
Feb 19 '15 at 22:30
5
I tried this... now when I runnode
I get this errorbash: /usr/bin/node: No such file or directory
what should I do ?
– Yerko Palma
Oct 11 '15 at 0:44
7
but still nodejs --version sow 0.10.25
– Mansuu....
Dec 29 '16 at 19:30
9
David Walsh says use NVM instead
– Ads20000
Jan 12 '17 at 12:15
|
show 20 more comments
10
this should be the correct answer.n
is a node helper package that installs or update a given node.js version.
– Martin
Oct 2 '14 at 12:38
37
I would advise strongly against doing this on a production instance. It can seriously mess stuff up with your global npm packages and your ability to install new ones.
– Loourr
Feb 19 '15 at 22:30
5
I tried this... now when I runnode
I get this errorbash: /usr/bin/node: No such file or directory
what should I do ?
– Yerko Palma
Oct 11 '15 at 0:44
7
but still nodejs --version sow 0.10.25
– Mansuu....
Dec 29 '16 at 19:30
9
David Walsh says use NVM instead
– Ads20000
Jan 12 '17 at 12:15
10
10
this should be the correct answer.
n
is a node helper package that installs or update a given node.js version.– Martin
Oct 2 '14 at 12:38
this should be the correct answer.
n
is a node helper package that installs or update a given node.js version.– Martin
Oct 2 '14 at 12:38
37
37
I would advise strongly against doing this on a production instance. It can seriously mess stuff up with your global npm packages and your ability to install new ones.
– Loourr
Feb 19 '15 at 22:30
I would advise strongly against doing this on a production instance. It can seriously mess stuff up with your global npm packages and your ability to install new ones.
– Loourr
Feb 19 '15 at 22:30
5
5
I tried this... now when I run
node
I get this error bash: /usr/bin/node: No such file or directory
what should I do ?– Yerko Palma
Oct 11 '15 at 0:44
I tried this... now when I run
node
I get this error bash: /usr/bin/node: No such file or directory
what should I do ?– Yerko Palma
Oct 11 '15 at 0:44
7
7
but still nodejs --version sow 0.10.25
– Mansuu....
Dec 29 '16 at 19:30
but still nodejs --version sow 0.10.25
– Mansuu....
Dec 29 '16 at 19:30
9
9
David Walsh says use NVM instead
– Ads20000
Jan 12 '17 at 12:15
David Walsh says use NVM instead
– Ads20000
Jan 12 '17 at 12:15
|
show 20 more comments
Complete installation instructions have since been uploaded here by Nodesource. It is copied below for your reference. Instructions are the same for updating to the latest version.
Node.js v10.x:
NOTE: If you are using Ubuntu Precise or Debian Wheezy, you might want to read about running Node.js >= 6.x on older distros
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_10.x | bash -
apt-get install -y nodejs
Node.js v9.x:
NOTE: If you are using Ubuntu Precise or Debian Wheezy, you might want to read about running Node.js >= 6.x on older distros
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_9.x | bash -
apt-get install -y nodejs
Node.js v8.x:
NOTE: If you are using Ubuntu Precise or Debian Wheezy, you might want to read about running Node.js >= 6.x on older distros
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_8.x | bash -
apt-get install -y nodejs
Node.js v7.x:
NOTE: Debian Wheezy and Ubuntu Precise packages are NOT available for this release. Please reference running Node.js >= 4.x on older distros
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_7.x | bash -
apt-get install -y nodejs
Node.js v6.x:
NOTE: If you are using Ubuntu Precise or Debian Wheezy, you might want to read about running Node.js >= 4.x on older distros.
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_6.x | bash -
apt-get install -y nodejs
Node.js v5.x:
NOTE: If you are using Ubuntu Precise or Debian Wheezy, you might want to read about running Node.js >= 4.x on older distros.
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_5.x | bash -
apt-get install -y nodejs
Node.js v4.x:
NOTE: If you are using Ubuntu Precise or Debian Wheezy, you might want to read about running Node.js >= 4.x on older distros.
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_4.x | bash -
apt-get install -y nodejs
Node.js v0.12:
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_0.12 | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_0.12 | bash -
apt-get install -y nodejs
Node.js v0.10:
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_0.10 | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_0.10 | bash -
apt-get install -y nodejs
io.js v3.x:
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_iojs_3.x | sudo -E bash -
sudo apt-get install -y iojs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_iojs_3.x | bash -
apt-get install -y iojs
io.js v2.x:
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_iojs_2.x | sudo -E bash -
sudo apt-get install -y iojs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_iojs_2.x | bash -
apt-get install -y iojs
io.js v1.x:
Note: this branch of io.js is not actively maintained and is not recommended for production use.
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_iojs_1.x | sudo -E bash -
sudo apt-get install -y iojs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_iojs_1.x | bash -
apt-get install -y iojs
I'd advise either removing the outdated information, or moving them to the bottom of the question, so that the current info is read first.
– k0pernikus
Dec 3 '15 at 16:05
@k0pernikus How's that? :p
– dayuloli
Dec 4 '15 at 2:44
Awesome :) I installed node4 yesterday after reading. It's outdated already ^^
– k0pernikus
Dec 4 '15 at 19:04
2
This is the answer that worked for me!
– eri0o
Mar 12 '16 at 4:16
For menode --version
still said "0.12.0". I had torm /usr/local/bin/node
, then I was able to use the newly installed version of nodejs.
– Ludachrispeed
Jul 17 '16 at 16:21
|
show 4 more comments
Complete installation instructions have since been uploaded here by Nodesource. It is copied below for your reference. Instructions are the same for updating to the latest version.
Node.js v10.x:
NOTE: If you are using Ubuntu Precise or Debian Wheezy, you might want to read about running Node.js >= 6.x on older distros
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_10.x | bash -
apt-get install -y nodejs
Node.js v9.x:
NOTE: If you are using Ubuntu Precise or Debian Wheezy, you might want to read about running Node.js >= 6.x on older distros
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_9.x | bash -
apt-get install -y nodejs
Node.js v8.x:
NOTE: If you are using Ubuntu Precise or Debian Wheezy, you might want to read about running Node.js >= 6.x on older distros
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_8.x | bash -
apt-get install -y nodejs
Node.js v7.x:
NOTE: Debian Wheezy and Ubuntu Precise packages are NOT available for this release. Please reference running Node.js >= 4.x on older distros
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_7.x | bash -
apt-get install -y nodejs
Node.js v6.x:
NOTE: If you are using Ubuntu Precise or Debian Wheezy, you might want to read about running Node.js >= 4.x on older distros.
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_6.x | bash -
apt-get install -y nodejs
Node.js v5.x:
NOTE: If you are using Ubuntu Precise or Debian Wheezy, you might want to read about running Node.js >= 4.x on older distros.
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_5.x | bash -
apt-get install -y nodejs
Node.js v4.x:
NOTE: If you are using Ubuntu Precise or Debian Wheezy, you might want to read about running Node.js >= 4.x on older distros.
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_4.x | bash -
apt-get install -y nodejs
Node.js v0.12:
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_0.12 | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_0.12 | bash -
apt-get install -y nodejs
Node.js v0.10:
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_0.10 | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_0.10 | bash -
apt-get install -y nodejs
io.js v3.x:
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_iojs_3.x | sudo -E bash -
sudo apt-get install -y iojs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_iojs_3.x | bash -
apt-get install -y iojs
io.js v2.x:
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_iojs_2.x | sudo -E bash -
sudo apt-get install -y iojs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_iojs_2.x | bash -
apt-get install -y iojs
io.js v1.x:
Note: this branch of io.js is not actively maintained and is not recommended for production use.
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_iojs_1.x | sudo -E bash -
sudo apt-get install -y iojs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_iojs_1.x | bash -
apt-get install -y iojs
I'd advise either removing the outdated information, or moving them to the bottom of the question, so that the current info is read first.
– k0pernikus
Dec 3 '15 at 16:05
@k0pernikus How's that? :p
– dayuloli
Dec 4 '15 at 2:44
Awesome :) I installed node4 yesterday after reading. It's outdated already ^^
– k0pernikus
Dec 4 '15 at 19:04
2
This is the answer that worked for me!
– eri0o
Mar 12 '16 at 4:16
For menode --version
still said "0.12.0". I had torm /usr/local/bin/node
, then I was able to use the newly installed version of nodejs.
– Ludachrispeed
Jul 17 '16 at 16:21
|
show 4 more comments
Complete installation instructions have since been uploaded here by Nodesource. It is copied below for your reference. Instructions are the same for updating to the latest version.
Node.js v10.x:
NOTE: If you are using Ubuntu Precise or Debian Wheezy, you might want to read about running Node.js >= 6.x on older distros
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_10.x | bash -
apt-get install -y nodejs
Node.js v9.x:
NOTE: If you are using Ubuntu Precise or Debian Wheezy, you might want to read about running Node.js >= 6.x on older distros
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_9.x | bash -
apt-get install -y nodejs
Node.js v8.x:
NOTE: If you are using Ubuntu Precise or Debian Wheezy, you might want to read about running Node.js >= 6.x on older distros
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_8.x | bash -
apt-get install -y nodejs
Node.js v7.x:
NOTE: Debian Wheezy and Ubuntu Precise packages are NOT available for this release. Please reference running Node.js >= 4.x on older distros
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_7.x | bash -
apt-get install -y nodejs
Node.js v6.x:
NOTE: If you are using Ubuntu Precise or Debian Wheezy, you might want to read about running Node.js >= 4.x on older distros.
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_6.x | bash -
apt-get install -y nodejs
Node.js v5.x:
NOTE: If you are using Ubuntu Precise or Debian Wheezy, you might want to read about running Node.js >= 4.x on older distros.
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_5.x | bash -
apt-get install -y nodejs
Node.js v4.x:
NOTE: If you are using Ubuntu Precise or Debian Wheezy, you might want to read about running Node.js >= 4.x on older distros.
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_4.x | bash -
apt-get install -y nodejs
Node.js v0.12:
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_0.12 | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_0.12 | bash -
apt-get install -y nodejs
Node.js v0.10:
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_0.10 | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_0.10 | bash -
apt-get install -y nodejs
io.js v3.x:
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_iojs_3.x | sudo -E bash -
sudo apt-get install -y iojs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_iojs_3.x | bash -
apt-get install -y iojs
io.js v2.x:
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_iojs_2.x | sudo -E bash -
sudo apt-get install -y iojs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_iojs_2.x | bash -
apt-get install -y iojs
io.js v1.x:
Note: this branch of io.js is not actively maintained and is not recommended for production use.
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_iojs_1.x | sudo -E bash -
sudo apt-get install -y iojs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_iojs_1.x | bash -
apt-get install -y iojs
Complete installation instructions have since been uploaded here by Nodesource. It is copied below for your reference. Instructions are the same for updating to the latest version.
Node.js v10.x:
NOTE: If you are using Ubuntu Precise or Debian Wheezy, you might want to read about running Node.js >= 6.x on older distros
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_10.x | bash -
apt-get install -y nodejs
Node.js v9.x:
NOTE: If you are using Ubuntu Precise or Debian Wheezy, you might want to read about running Node.js >= 6.x on older distros
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_9.x | bash -
apt-get install -y nodejs
Node.js v8.x:
NOTE: If you are using Ubuntu Precise or Debian Wheezy, you might want to read about running Node.js >= 6.x on older distros
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_8.x | bash -
apt-get install -y nodejs
Node.js v7.x:
NOTE: Debian Wheezy and Ubuntu Precise packages are NOT available for this release. Please reference running Node.js >= 4.x on older distros
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_7.x | bash -
apt-get install -y nodejs
Node.js v6.x:
NOTE: If you are using Ubuntu Precise or Debian Wheezy, you might want to read about running Node.js >= 4.x on older distros.
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_6.x | bash -
apt-get install -y nodejs
Node.js v5.x:
NOTE: If you are using Ubuntu Precise or Debian Wheezy, you might want to read about running Node.js >= 4.x on older distros.
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_5.x | bash -
apt-get install -y nodejs
Node.js v4.x:
NOTE: If you are using Ubuntu Precise or Debian Wheezy, you might want to read about running Node.js >= 4.x on older distros.
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_4.x | bash -
apt-get install -y nodejs
Node.js v0.12:
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_0.12 | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_0.12 | bash -
apt-get install -y nodejs
Node.js v0.10:
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_0.10 | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_0.10 | bash -
apt-get install -y nodejs
io.js v3.x:
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_iojs_3.x | sudo -E bash -
sudo apt-get install -y iojs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_iojs_3.x | bash -
apt-get install -y iojs
io.js v2.x:
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_iojs_2.x | sudo -E bash -
sudo apt-get install -y iojs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_iojs_2.x | bash -
apt-get install -y iojs
io.js v1.x:
Note: this branch of io.js is not actively maintained and is not recommended for production use.
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_iojs_1.x | sudo -E bash -
sudo apt-get install -y iojs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_iojs_1.x | bash -
apt-get install -y iojs
edited May 14 '18 at 20:07
Paulo Coghi
72531639
72531639
answered Nov 12 '14 at 14:54
dayulolidayuloli
3,58111122
3,58111122
I'd advise either removing the outdated information, or moving them to the bottom of the question, so that the current info is read first.
– k0pernikus
Dec 3 '15 at 16:05
@k0pernikus How's that? :p
– dayuloli
Dec 4 '15 at 2:44
Awesome :) I installed node4 yesterday after reading. It's outdated already ^^
– k0pernikus
Dec 4 '15 at 19:04
2
This is the answer that worked for me!
– eri0o
Mar 12 '16 at 4:16
For menode --version
still said "0.12.0". I had torm /usr/local/bin/node
, then I was able to use the newly installed version of nodejs.
– Ludachrispeed
Jul 17 '16 at 16:21
|
show 4 more comments
I'd advise either removing the outdated information, or moving them to the bottom of the question, so that the current info is read first.
– k0pernikus
Dec 3 '15 at 16:05
@k0pernikus How's that? :p
– dayuloli
Dec 4 '15 at 2:44
Awesome :) I installed node4 yesterday after reading. It's outdated already ^^
– k0pernikus
Dec 4 '15 at 19:04
2
This is the answer that worked for me!
– eri0o
Mar 12 '16 at 4:16
For menode --version
still said "0.12.0". I had torm /usr/local/bin/node
, then I was able to use the newly installed version of nodejs.
– Ludachrispeed
Jul 17 '16 at 16:21
I'd advise either removing the outdated information, or moving them to the bottom of the question, so that the current info is read first.
– k0pernikus
Dec 3 '15 at 16:05
I'd advise either removing the outdated information, or moving them to the bottom of the question, so that the current info is read first.
– k0pernikus
Dec 3 '15 at 16:05
@k0pernikus How's that? :p
– dayuloli
Dec 4 '15 at 2:44
@k0pernikus How's that? :p
– dayuloli
Dec 4 '15 at 2:44
Awesome :) I installed node4 yesterday after reading. It's outdated already ^^
– k0pernikus
Dec 4 '15 at 19:04
Awesome :) I installed node4 yesterday after reading. It's outdated already ^^
– k0pernikus
Dec 4 '15 at 19:04
2
2
This is the answer that worked for me!
– eri0o
Mar 12 '16 at 4:16
This is the answer that worked for me!
– eri0o
Mar 12 '16 at 4:16
For me
node --version
still said "0.12.0". I had to rm /usr/local/bin/node
, then I was able to use the newly installed version of nodejs.– Ludachrispeed
Jul 17 '16 at 16:21
For me
node --version
still said "0.12.0". I had to rm /usr/local/bin/node
, then I was able to use the newly installed version of nodejs.– Ludachrispeed
Jul 17 '16 at 16:21
|
show 4 more comments
This PPA is out of date and not maintained anymore; you should consider other answers instead of this one.
You can install the latest version from PPA:
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs
12
I think this would be a better answer if you (also) provided a non-ppa way of doing this, ppas are notoriously known for becoming outdated and unmaintained, essentially making the answer useless.
– pzkpfw
Feb 27 '14 at 16:21
@bigbadonk420 yeah, if you just googled it, probably better to skip the first line and do just update and install-worked for me with node 0.10.34
– Capaj
Dec 22 '14 at 11:46
@Capaj nope. that didn't help...
– deostroll
Dec 24 '14 at 0:47
6
Don't recommend using this ppa any more, it seems to be rather out of date.
– Kzqai
Dec 2 '15 at 12:12
add a comment |
This PPA is out of date and not maintained anymore; you should consider other answers instead of this one.
You can install the latest version from PPA:
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs
12
I think this would be a better answer if you (also) provided a non-ppa way of doing this, ppas are notoriously known for becoming outdated and unmaintained, essentially making the answer useless.
– pzkpfw
Feb 27 '14 at 16:21
@bigbadonk420 yeah, if you just googled it, probably better to skip the first line and do just update and install-worked for me with node 0.10.34
– Capaj
Dec 22 '14 at 11:46
@Capaj nope. that didn't help...
– deostroll
Dec 24 '14 at 0:47
6
Don't recommend using this ppa any more, it seems to be rather out of date.
– Kzqai
Dec 2 '15 at 12:12
add a comment |
This PPA is out of date and not maintained anymore; you should consider other answers instead of this one.
You can install the latest version from PPA:
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs
This PPA is out of date and not maintained anymore; you should consider other answers instead of this one.
You can install the latest version from PPA:
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs
edited Nov 17 '16 at 23:13
Thomas Ward♦
45k23125178
45k23125178
answered Feb 26 '14 at 21:47
Walid SaadWalid Saad
40534
40534
12
I think this would be a better answer if you (also) provided a non-ppa way of doing this, ppas are notoriously known for becoming outdated and unmaintained, essentially making the answer useless.
– pzkpfw
Feb 27 '14 at 16:21
@bigbadonk420 yeah, if you just googled it, probably better to skip the first line and do just update and install-worked for me with node 0.10.34
– Capaj
Dec 22 '14 at 11:46
@Capaj nope. that didn't help...
– deostroll
Dec 24 '14 at 0:47
6
Don't recommend using this ppa any more, it seems to be rather out of date.
– Kzqai
Dec 2 '15 at 12:12
add a comment |
12
I think this would be a better answer if you (also) provided a non-ppa way of doing this, ppas are notoriously known for becoming outdated and unmaintained, essentially making the answer useless.
– pzkpfw
Feb 27 '14 at 16:21
@bigbadonk420 yeah, if you just googled it, probably better to skip the first line and do just update and install-worked for me with node 0.10.34
– Capaj
Dec 22 '14 at 11:46
@Capaj nope. that didn't help...
– deostroll
Dec 24 '14 at 0:47
6
Don't recommend using this ppa any more, it seems to be rather out of date.
– Kzqai
Dec 2 '15 at 12:12
12
12
I think this would be a better answer if you (also) provided a non-ppa way of doing this, ppas are notoriously known for becoming outdated and unmaintained, essentially making the answer useless.
– pzkpfw
Feb 27 '14 at 16:21
I think this would be a better answer if you (also) provided a non-ppa way of doing this, ppas are notoriously known for becoming outdated and unmaintained, essentially making the answer useless.
– pzkpfw
Feb 27 '14 at 16:21
@bigbadonk420 yeah, if you just googled it, probably better to skip the first line and do just update and install-worked for me with node 0.10.34
– Capaj
Dec 22 '14 at 11:46
@bigbadonk420 yeah, if you just googled it, probably better to skip the first line and do just update and install-worked for me with node 0.10.34
– Capaj
Dec 22 '14 at 11:46
@Capaj nope. that didn't help...
– deostroll
Dec 24 '14 at 0:47
@Capaj nope. that didn't help...
– deostroll
Dec 24 '14 at 0:47
6
6
Don't recommend using this ppa any more, it seems to be rather out of date.
– Kzqai
Dec 2 '15 at 12:12
Don't recommend using this ppa any more, it seems to be rather out of date.
– Kzqai
Dec 2 '15 at 12:12
add a comment |
I use NVM to handle my Node versions. Very simple to set up and easy to use.
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
To install NVM globally instead, use the following curl command instead of the one above (and presumably don't use the second command but do use the third one)
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | NVM_DIR=/usr/local/nvm bash
Then use nvm install stable
(or insert a version number instead of stable
) to get the latest/a specific version of Node. Use nvm use stable
(or a specific version number) to use that Node version. Use nvm ls
to see what Node versions you have installed and nvm uninstall stable
(or a specific version number) to remove a specific version of Node.
Sources:
Install, usage
Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.
– Warren Hill
Mar 31 '14 at 14:30
Apologies for my noobness. Updated answer
– amnah
Mar 31 '14 at 16:27
the given curl path is not working. I used "curl raw.githubusercontent.com/creationix/nvm/v0.13.1/install.sh | bash" as given in the github.com/creationix/nvm
– Senthil
Aug 18 '14 at 3:35
Don't forget to update the url part to the latest version of nvm
– Nidhin David
Oct 21 '16 at 6:59
add a comment |
I use NVM to handle my Node versions. Very simple to set up and easy to use.
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
To install NVM globally instead, use the following curl command instead of the one above (and presumably don't use the second command but do use the third one)
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | NVM_DIR=/usr/local/nvm bash
Then use nvm install stable
(or insert a version number instead of stable
) to get the latest/a specific version of Node. Use nvm use stable
(or a specific version number) to use that Node version. Use nvm ls
to see what Node versions you have installed and nvm uninstall stable
(or a specific version number) to remove a specific version of Node.
Sources:
Install, usage
Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.
– Warren Hill
Mar 31 '14 at 14:30
Apologies for my noobness. Updated answer
– amnah
Mar 31 '14 at 16:27
the given curl path is not working. I used "curl raw.githubusercontent.com/creationix/nvm/v0.13.1/install.sh | bash" as given in the github.com/creationix/nvm
– Senthil
Aug 18 '14 at 3:35
Don't forget to update the url part to the latest version of nvm
– Nidhin David
Oct 21 '16 at 6:59
add a comment |
I use NVM to handle my Node versions. Very simple to set up and easy to use.
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
To install NVM globally instead, use the following curl command instead of the one above (and presumably don't use the second command but do use the third one)
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | NVM_DIR=/usr/local/nvm bash
Then use nvm install stable
(or insert a version number instead of stable
) to get the latest/a specific version of Node. Use nvm use stable
(or a specific version number) to use that Node version. Use nvm ls
to see what Node versions you have installed and nvm uninstall stable
(or a specific version number) to remove a specific version of Node.
Sources:
Install, usage
I use NVM to handle my Node versions. Very simple to set up and easy to use.
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
To install NVM globally instead, use the following curl command instead of the one above (and presumably don't use the second command but do use the third one)
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | NVM_DIR=/usr/local/nvm bash
Then use nvm install stable
(or insert a version number instead of stable
) to get the latest/a specific version of Node. Use nvm use stable
(or a specific version number) to use that Node version. Use nvm ls
to see what Node versions you have installed and nvm uninstall stable
(or a specific version number) to remove a specific version of Node.
Sources:
Install, usage
edited Jan 12 '17 at 13:50
Ads20000
1,57911228
1,57911228
answered Mar 31 '14 at 14:00
amnahamnah
1794
1794
Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.
– Warren Hill
Mar 31 '14 at 14:30
Apologies for my noobness. Updated answer
– amnah
Mar 31 '14 at 16:27
the given curl path is not working. I used "curl raw.githubusercontent.com/creationix/nvm/v0.13.1/install.sh | bash" as given in the github.com/creationix/nvm
– Senthil
Aug 18 '14 at 3:35
Don't forget to update the url part to the latest version of nvm
– Nidhin David
Oct 21 '16 at 6:59
add a comment |
Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.
– Warren Hill
Mar 31 '14 at 14:30
Apologies for my noobness. Updated answer
– amnah
Mar 31 '14 at 16:27
the given curl path is not working. I used "curl raw.githubusercontent.com/creationix/nvm/v0.13.1/install.sh | bash" as given in the github.com/creationix/nvm
– Senthil
Aug 18 '14 at 3:35
Don't forget to update the url part to the latest version of nvm
– Nidhin David
Oct 21 '16 at 6:59
Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.
– Warren Hill
Mar 31 '14 at 14:30
Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.
– Warren Hill
Mar 31 '14 at 14:30
Apologies for my noobness. Updated answer
– amnah
Mar 31 '14 at 16:27
Apologies for my noobness. Updated answer
– amnah
Mar 31 '14 at 16:27
the given curl path is not working. I used "curl raw.githubusercontent.com/creationix/nvm/v0.13.1/install.sh | bash" as given in the github.com/creationix/nvm
– Senthil
Aug 18 '14 at 3:35
the given curl path is not working. I used "curl raw.githubusercontent.com/creationix/nvm/v0.13.1/install.sh | bash" as given in the github.com/creationix/nvm
– Senthil
Aug 18 '14 at 3:35
Don't forget to update the url part to the latest version of nvm
– Nidhin David
Oct 21 '16 at 6:59
Don't forget to update the url part to the latest version of nvm
– Nidhin David
Oct 21 '16 at 6:59
add a comment |
I also recommend using nvm instead, and also removing the already installed version to avoid conflicts in the terminal
sudo apt purge nodejs npm
then install nvm and use it
Video Explanation
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
to download and install nvm
nvm install node
should download and install the latest version of node.
To update node later on just do
nvm install node
nvm alias default node
2
This should be the only accepted answer - in case you want to have a sane and up to date Node setup in Ubuntu.
– José L. Patiño
Aug 20 '18 at 13:35
add a comment |
I also recommend using nvm instead, and also removing the already installed version to avoid conflicts in the terminal
sudo apt purge nodejs npm
then install nvm and use it
Video Explanation
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
to download and install nvm
nvm install node
should download and install the latest version of node.
To update node later on just do
nvm install node
nvm alias default node
2
This should be the only accepted answer - in case you want to have a sane and up to date Node setup in Ubuntu.
– José L. Patiño
Aug 20 '18 at 13:35
add a comment |
I also recommend using nvm instead, and also removing the already installed version to avoid conflicts in the terminal
sudo apt purge nodejs npm
then install nvm and use it
Video Explanation
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
to download and install nvm
nvm install node
should download and install the latest version of node.
To update node later on just do
nvm install node
nvm alias default node
I also recommend using nvm instead, and also removing the already installed version to avoid conflicts in the terminal
sudo apt purge nodejs npm
then install nvm and use it
Video Explanation
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
to download and install nvm
nvm install node
should download and install the latest version of node.
To update node later on just do
nvm install node
nvm alias default node
answered Feb 25 '18 at 7:17
Mina MichaelMina Michael
4,2121860122
4,2121860122
2
This should be the only accepted answer - in case you want to have a sane and up to date Node setup in Ubuntu.
– José L. Patiño
Aug 20 '18 at 13:35
add a comment |
2
This should be the only accepted answer - in case you want to have a sane and up to date Node setup in Ubuntu.
– José L. Patiño
Aug 20 '18 at 13:35
2
2
This should be the only accepted answer - in case you want to have a sane and up to date Node setup in Ubuntu.
– José L. Patiño
Aug 20 '18 at 13:35
This should be the only accepted answer - in case you want to have a sane and up to date Node setup in Ubuntu.
– José L. Patiño
Aug 20 '18 at 13:35
add a comment |
I tried the same list commands on my ubuntu 14.04 but it was still throwing an error.
Commands I executed were:
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs
and the error i was getting:
Invalid version 0.12.2
Line 299: curl not found in /bin/n
What I figured out was curl utility was not installed on my os.
I executed command:
apt-get install curl
(use sudo
as prefix if you are not su
)
and then repeated the steps suggest in answer and it work ;)
add a comment |
I tried the same list commands on my ubuntu 14.04 but it was still throwing an error.
Commands I executed were:
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs
and the error i was getting:
Invalid version 0.12.2
Line 299: curl not found in /bin/n
What I figured out was curl utility was not installed on my os.
I executed command:
apt-get install curl
(use sudo
as prefix if you are not su
)
and then repeated the steps suggest in answer and it work ;)
add a comment |
I tried the same list commands on my ubuntu 14.04 but it was still throwing an error.
Commands I executed were:
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs
and the error i was getting:
Invalid version 0.12.2
Line 299: curl not found in /bin/n
What I figured out was curl utility was not installed on my os.
I executed command:
apt-get install curl
(use sudo
as prefix if you are not su
)
and then repeated the steps suggest in answer and it work ;)
I tried the same list commands on my ubuntu 14.04 but it was still throwing an error.
Commands I executed were:
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs
and the error i was getting:
Invalid version 0.12.2
Line 299: curl not found in /bin/n
What I figured out was curl utility was not installed on my os.
I executed command:
apt-get install curl
(use sudo
as prefix if you are not su
)
and then repeated the steps suggest in answer and it work ;)
edited Apr 12 '15 at 5:22
Faizan Akram Dar
3,82311629
3,82311629
answered Apr 12 '15 at 4:43
Priyank ThakkarPriyank Thakkar
1414
1414
add a comment |
add a comment |
This one installs the latest node v0.12.* from nodesource.
sudo apt-get install -y curl
curl -sL https://deb.nodesource.com/setup_0.12 | sudo bash -
sudo apt-get install -y nodejs
For node v4.x
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs
2
Are you installing node from scratch? The question was about updating not installing
– Green
Feb 24 '17 at 5:56
add a comment |
This one installs the latest node v0.12.* from nodesource.
sudo apt-get install -y curl
curl -sL https://deb.nodesource.com/setup_0.12 | sudo bash -
sudo apt-get install -y nodejs
For node v4.x
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs
2
Are you installing node from scratch? The question was about updating not installing
– Green
Feb 24 '17 at 5:56
add a comment |
This one installs the latest node v0.12.* from nodesource.
sudo apt-get install -y curl
curl -sL https://deb.nodesource.com/setup_0.12 | sudo bash -
sudo apt-get install -y nodejs
For node v4.x
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs
This one installs the latest node v0.12.* from nodesource.
sudo apt-get install -y curl
curl -sL https://deb.nodesource.com/setup_0.12 | sudo bash -
sudo apt-get install -y nodejs
For node v4.x
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs
edited Dec 2 '15 at 12:16
answered May 13 '15 at 12:17
Kunal KapadiaKunal Kapadia
1292
1292
2
Are you installing node from scratch? The question was about updating not installing
– Green
Feb 24 '17 at 5:56
add a comment |
2
Are you installing node from scratch? The question was about updating not installing
– Green
Feb 24 '17 at 5:56
2
2
Are you installing node from scratch? The question was about updating not installing
– Green
Feb 24 '17 at 5:56
Are you installing node from scratch? The question was about updating not installing
– Green
Feb 24 '17 at 5:56
add a comment |
I suggest you first remove all nodejs installs
then execute below script once you edit with desired nodejs version and its install parent directory
see all available nodejs versions
https://nodejs.org/dist/
below script will allow you to install any of those nodejs versions on linux or OSX
#!/bin/bash
# usage :
#
# edit two vars in below : NODE_VER and CODE_PARENT_DIR
#
# ... execute this script as yourself unless you choose a root owned value for var CODE_PARENT_DIR
# whichever id you execute this as determines the id you will issue npm commands as : npm install -g foo-bar
#
# NOTE - nodejs comes bundled with npm ... so no need to do separate npm install
# this scripts runs fine on linux or OSX
# ... copy all the lines starting here .. top of copy .... and ending ... end of copy ...
# and paste into your ~/.bashrc file so proper env vars get set
# ............... top of copy ........................ install_node.sh
# export NODE_VER=v7.2.0 # see available versions at https://nodejs.org/dist/
# export NODE_VER=v8.5.0 # edit this line next time you need to update nodejs
export NODE_VER=v9.3.0 # edit this line next time you need to update nodejs
# ... pick parent dir of nodejs install ... comment out or remove ONE of below
# export CODE_PARENT_DIR=/opt/code # root owned dir ... requires you to sudo prior to npm install going forward
export CODE_PARENT_DIR=${HOME} # RECOMMENDED execute as yourself including npm install
# ......... following env vars are OK no edits needed ... only ever need to edit above vars
curr_OS=$( uname )
echo curr_OS $curr_OS
if [[ "${curr_OS}" == "Darwin" ]]; then
OS_ARCH=darwin-x64
elif [[ "${curr_OS}" == "Linux" ]]; then
OS_ARCH=linux-x64
else
echo "ERROR - failed to recognize OS $curr_OS"
exit 5
fi
if [[ -z ${CODE_PARENT_DIR} ]]; then
echo "ERROR - failed to see env var CODE_PARENT_DIR"
exit 5
fi
export NODE_CODEDIR=${CODE_PARENT_DIR}/nodejs
export COMSUFFIX=tar.gz
export NODE_NAME=node-${NODE_VER}
export NODE_PARENT=${NODE_CODEDIR}/${NODE_NAME}-${OS_ARCH}
export PATH=${NODE_PARENT}/bin:${PATH}
export NODE_PATH=${NODE_PARENT}/lib/node_modules
# ............... end of copy ........................ install_node.sh
# copy and paste above from ... top of copy ... to here into your file ~/.bashrc
echo
echo "NODE_CODEDIR $NODE_CODEDIR<--"
echo
echo "mkdir -p ${NODE_CODEDIR}"
echo
mkdir -p ${NODE_CODEDIR}
echo
echo "cd ${NODE_CODEDIR}"
cd ${NODE_CODEDIR}
echo
# this is compiled code NOT source
[ -f ${NODE_NAME}-${OS_ARCH}.${COMSUFFIX} ] && rm ${NODE_NAME}-${OS_ARCH}.${COMSUFFIX} # if file exists remove
echo "wget -q --show-progress https://nodejs.org/download/release/${NODE_VER}/${NODE_NAME}-${OS_ARCH}.${COMSUFFIX}"
wget -q --show-progress https://nodejs.org/download/release/${NODE_VER}/${NODE_NAME}-${OS_ARCH}.${COMSUFFIX}
echo
echo "tar -C ${NODE_CODEDIR} -xf ${NODE_NAME}-${OS_ARCH}.${COMSUFFIX}"
tar -C ${NODE_CODEDIR} -xf ${NODE_NAME}-${OS_ARCH}.${COMSUFFIX}
echo
[ -f ${NODE_NAME}-${OS_ARCH}.${COMSUFFIX} ] && rm ${NODE_NAME}-${OS_ARCH}.${COMSUFFIX} # if file exists remove
# ........... done ........... #
which node
node --version
# .... bottom of file install_node.sh
add a comment |
I suggest you first remove all nodejs installs
then execute below script once you edit with desired nodejs version and its install parent directory
see all available nodejs versions
https://nodejs.org/dist/
below script will allow you to install any of those nodejs versions on linux or OSX
#!/bin/bash
# usage :
#
# edit two vars in below : NODE_VER and CODE_PARENT_DIR
#
# ... execute this script as yourself unless you choose a root owned value for var CODE_PARENT_DIR
# whichever id you execute this as determines the id you will issue npm commands as : npm install -g foo-bar
#
# NOTE - nodejs comes bundled with npm ... so no need to do separate npm install
# this scripts runs fine on linux or OSX
# ... copy all the lines starting here .. top of copy .... and ending ... end of copy ...
# and paste into your ~/.bashrc file so proper env vars get set
# ............... top of copy ........................ install_node.sh
# export NODE_VER=v7.2.0 # see available versions at https://nodejs.org/dist/
# export NODE_VER=v8.5.0 # edit this line next time you need to update nodejs
export NODE_VER=v9.3.0 # edit this line next time you need to update nodejs
# ... pick parent dir of nodejs install ... comment out or remove ONE of below
# export CODE_PARENT_DIR=/opt/code # root owned dir ... requires you to sudo prior to npm install going forward
export CODE_PARENT_DIR=${HOME} # RECOMMENDED execute as yourself including npm install
# ......... following env vars are OK no edits needed ... only ever need to edit above vars
curr_OS=$( uname )
echo curr_OS $curr_OS
if [[ "${curr_OS}" == "Darwin" ]]; then
OS_ARCH=darwin-x64
elif [[ "${curr_OS}" == "Linux" ]]; then
OS_ARCH=linux-x64
else
echo "ERROR - failed to recognize OS $curr_OS"
exit 5
fi
if [[ -z ${CODE_PARENT_DIR} ]]; then
echo "ERROR - failed to see env var CODE_PARENT_DIR"
exit 5
fi
export NODE_CODEDIR=${CODE_PARENT_DIR}/nodejs
export COMSUFFIX=tar.gz
export NODE_NAME=node-${NODE_VER}
export NODE_PARENT=${NODE_CODEDIR}/${NODE_NAME}-${OS_ARCH}
export PATH=${NODE_PARENT}/bin:${PATH}
export NODE_PATH=${NODE_PARENT}/lib/node_modules
# ............... end of copy ........................ install_node.sh
# copy and paste above from ... top of copy ... to here into your file ~/.bashrc
echo
echo "NODE_CODEDIR $NODE_CODEDIR<--"
echo
echo "mkdir -p ${NODE_CODEDIR}"
echo
mkdir -p ${NODE_CODEDIR}
echo
echo "cd ${NODE_CODEDIR}"
cd ${NODE_CODEDIR}
echo
# this is compiled code NOT source
[ -f ${NODE_NAME}-${OS_ARCH}.${COMSUFFIX} ] && rm ${NODE_NAME}-${OS_ARCH}.${COMSUFFIX} # if file exists remove
echo "wget -q --show-progress https://nodejs.org/download/release/${NODE_VER}/${NODE_NAME}-${OS_ARCH}.${COMSUFFIX}"
wget -q --show-progress https://nodejs.org/download/release/${NODE_VER}/${NODE_NAME}-${OS_ARCH}.${COMSUFFIX}
echo
echo "tar -C ${NODE_CODEDIR} -xf ${NODE_NAME}-${OS_ARCH}.${COMSUFFIX}"
tar -C ${NODE_CODEDIR} -xf ${NODE_NAME}-${OS_ARCH}.${COMSUFFIX}
echo
[ -f ${NODE_NAME}-${OS_ARCH}.${COMSUFFIX} ] && rm ${NODE_NAME}-${OS_ARCH}.${COMSUFFIX} # if file exists remove
# ........... done ........... #
which node
node --version
# .... bottom of file install_node.sh
add a comment |
I suggest you first remove all nodejs installs
then execute below script once you edit with desired nodejs version and its install parent directory
see all available nodejs versions
https://nodejs.org/dist/
below script will allow you to install any of those nodejs versions on linux or OSX
#!/bin/bash
# usage :
#
# edit two vars in below : NODE_VER and CODE_PARENT_DIR
#
# ... execute this script as yourself unless you choose a root owned value for var CODE_PARENT_DIR
# whichever id you execute this as determines the id you will issue npm commands as : npm install -g foo-bar
#
# NOTE - nodejs comes bundled with npm ... so no need to do separate npm install
# this scripts runs fine on linux or OSX
# ... copy all the lines starting here .. top of copy .... and ending ... end of copy ...
# and paste into your ~/.bashrc file so proper env vars get set
# ............... top of copy ........................ install_node.sh
# export NODE_VER=v7.2.0 # see available versions at https://nodejs.org/dist/
# export NODE_VER=v8.5.0 # edit this line next time you need to update nodejs
export NODE_VER=v9.3.0 # edit this line next time you need to update nodejs
# ... pick parent dir of nodejs install ... comment out or remove ONE of below
# export CODE_PARENT_DIR=/opt/code # root owned dir ... requires you to sudo prior to npm install going forward
export CODE_PARENT_DIR=${HOME} # RECOMMENDED execute as yourself including npm install
# ......... following env vars are OK no edits needed ... only ever need to edit above vars
curr_OS=$( uname )
echo curr_OS $curr_OS
if [[ "${curr_OS}" == "Darwin" ]]; then
OS_ARCH=darwin-x64
elif [[ "${curr_OS}" == "Linux" ]]; then
OS_ARCH=linux-x64
else
echo "ERROR - failed to recognize OS $curr_OS"
exit 5
fi
if [[ -z ${CODE_PARENT_DIR} ]]; then
echo "ERROR - failed to see env var CODE_PARENT_DIR"
exit 5
fi
export NODE_CODEDIR=${CODE_PARENT_DIR}/nodejs
export COMSUFFIX=tar.gz
export NODE_NAME=node-${NODE_VER}
export NODE_PARENT=${NODE_CODEDIR}/${NODE_NAME}-${OS_ARCH}
export PATH=${NODE_PARENT}/bin:${PATH}
export NODE_PATH=${NODE_PARENT}/lib/node_modules
# ............... end of copy ........................ install_node.sh
# copy and paste above from ... top of copy ... to here into your file ~/.bashrc
echo
echo "NODE_CODEDIR $NODE_CODEDIR<--"
echo
echo "mkdir -p ${NODE_CODEDIR}"
echo
mkdir -p ${NODE_CODEDIR}
echo
echo "cd ${NODE_CODEDIR}"
cd ${NODE_CODEDIR}
echo
# this is compiled code NOT source
[ -f ${NODE_NAME}-${OS_ARCH}.${COMSUFFIX} ] && rm ${NODE_NAME}-${OS_ARCH}.${COMSUFFIX} # if file exists remove
echo "wget -q --show-progress https://nodejs.org/download/release/${NODE_VER}/${NODE_NAME}-${OS_ARCH}.${COMSUFFIX}"
wget -q --show-progress https://nodejs.org/download/release/${NODE_VER}/${NODE_NAME}-${OS_ARCH}.${COMSUFFIX}
echo
echo "tar -C ${NODE_CODEDIR} -xf ${NODE_NAME}-${OS_ARCH}.${COMSUFFIX}"
tar -C ${NODE_CODEDIR} -xf ${NODE_NAME}-${OS_ARCH}.${COMSUFFIX}
echo
[ -f ${NODE_NAME}-${OS_ARCH}.${COMSUFFIX} ] && rm ${NODE_NAME}-${OS_ARCH}.${COMSUFFIX} # if file exists remove
# ........... done ........... #
which node
node --version
# .... bottom of file install_node.sh
I suggest you first remove all nodejs installs
then execute below script once you edit with desired nodejs version and its install parent directory
see all available nodejs versions
https://nodejs.org/dist/
below script will allow you to install any of those nodejs versions on linux or OSX
#!/bin/bash
# usage :
#
# edit two vars in below : NODE_VER and CODE_PARENT_DIR
#
# ... execute this script as yourself unless you choose a root owned value for var CODE_PARENT_DIR
# whichever id you execute this as determines the id you will issue npm commands as : npm install -g foo-bar
#
# NOTE - nodejs comes bundled with npm ... so no need to do separate npm install
# this scripts runs fine on linux or OSX
# ... copy all the lines starting here .. top of copy .... and ending ... end of copy ...
# and paste into your ~/.bashrc file so proper env vars get set
# ............... top of copy ........................ install_node.sh
# export NODE_VER=v7.2.0 # see available versions at https://nodejs.org/dist/
# export NODE_VER=v8.5.0 # edit this line next time you need to update nodejs
export NODE_VER=v9.3.0 # edit this line next time you need to update nodejs
# ... pick parent dir of nodejs install ... comment out or remove ONE of below
# export CODE_PARENT_DIR=/opt/code # root owned dir ... requires you to sudo prior to npm install going forward
export CODE_PARENT_DIR=${HOME} # RECOMMENDED execute as yourself including npm install
# ......... following env vars are OK no edits needed ... only ever need to edit above vars
curr_OS=$( uname )
echo curr_OS $curr_OS
if [[ "${curr_OS}" == "Darwin" ]]; then
OS_ARCH=darwin-x64
elif [[ "${curr_OS}" == "Linux" ]]; then
OS_ARCH=linux-x64
else
echo "ERROR - failed to recognize OS $curr_OS"
exit 5
fi
if [[ -z ${CODE_PARENT_DIR} ]]; then
echo "ERROR - failed to see env var CODE_PARENT_DIR"
exit 5
fi
export NODE_CODEDIR=${CODE_PARENT_DIR}/nodejs
export COMSUFFIX=tar.gz
export NODE_NAME=node-${NODE_VER}
export NODE_PARENT=${NODE_CODEDIR}/${NODE_NAME}-${OS_ARCH}
export PATH=${NODE_PARENT}/bin:${PATH}
export NODE_PATH=${NODE_PARENT}/lib/node_modules
# ............... end of copy ........................ install_node.sh
# copy and paste above from ... top of copy ... to here into your file ~/.bashrc
echo
echo "NODE_CODEDIR $NODE_CODEDIR<--"
echo
echo "mkdir -p ${NODE_CODEDIR}"
echo
mkdir -p ${NODE_CODEDIR}
echo
echo "cd ${NODE_CODEDIR}"
cd ${NODE_CODEDIR}
echo
# this is compiled code NOT source
[ -f ${NODE_NAME}-${OS_ARCH}.${COMSUFFIX} ] && rm ${NODE_NAME}-${OS_ARCH}.${COMSUFFIX} # if file exists remove
echo "wget -q --show-progress https://nodejs.org/download/release/${NODE_VER}/${NODE_NAME}-${OS_ARCH}.${COMSUFFIX}"
wget -q --show-progress https://nodejs.org/download/release/${NODE_VER}/${NODE_NAME}-${OS_ARCH}.${COMSUFFIX}
echo
echo "tar -C ${NODE_CODEDIR} -xf ${NODE_NAME}-${OS_ARCH}.${COMSUFFIX}"
tar -C ${NODE_CODEDIR} -xf ${NODE_NAME}-${OS_ARCH}.${COMSUFFIX}
echo
[ -f ${NODE_NAME}-${OS_ARCH}.${COMSUFFIX} ] && rm ${NODE_NAME}-${OS_ARCH}.${COMSUFFIX} # if file exists remove
# ........... done ........... #
which node
node --version
# .... bottom of file install_node.sh
edited Dec 27 '17 at 23:59
answered Sep 25 '17 at 20:15
Scott StenslandScott Stensland
5,06242342
5,06242342
add a comment |
add a comment |
If using n
does not work, you can install the latest version of nodejs
(i. e. version 8) running the following commands:
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
Further instructions are here.
add a comment |
If using n
does not work, you can install the latest version of nodejs
(i. e. version 8) running the following commands:
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
Further instructions are here.
add a comment |
If using n
does not work, you can install the latest version of nodejs
(i. e. version 8) running the following commands:
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
Further instructions are here.
If using n
does not work, you can install the latest version of nodejs
(i. e. version 8) running the following commands:
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
Further instructions are here.
answered May 4 '18 at 13:32
smartmousesmartmouse
1563
1563
add a comment |
add a comment |
NVM (Node Version manager) with --lts
NVM was mentioned at: https://askubuntu.com/a/441527/52975 but here goes a more complete usage example, including the sane --lts
version.
NVM installs both the latest stable node and npm for you
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | sh
source ~/.nvm/nvm.sh
nvm install --lts
nvm use --lts
npm --version
Now test it out with a dummy package:
npm install --global vaca
vaca
Since the sourcing has to be done for every new shell, you will probably want to add the following to your .bashrc
:
f="$HOME/.nvm/nvm.sh"
if [ -r "$f" ]; then
. "$f" &>'/dev/null'
nvm use --lts &>'/dev/null'
fi
Advantages:
allows you to use multiple versions of Node and without sudo
is analogous to Ruby RVM and Python Virtualenv, widely considered best practice in Ruby and Python communities
downloads a pre-compiled binary where possible, and if not it downloads the source and compiles one for you
We can easily switch node versions with:
nvm install 0.9.0
nvm install 0.9.9
nvm use 0.9.0
node --version
#v0.9.0
nvm use 0.9.9
node --version
#v0.9.9
You can then use a git tracked .nvmrc
file to indicate the node version required for a given project: https://stackoverflow.com/questions/24869959/how-do-i-specify-a-local-version-of-node-for-a-project/54503474#54503474
Tested in Ubuntu 17.10.
add a comment |
NVM (Node Version manager) with --lts
NVM was mentioned at: https://askubuntu.com/a/441527/52975 but here goes a more complete usage example, including the sane --lts
version.
NVM installs both the latest stable node and npm for you
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | sh
source ~/.nvm/nvm.sh
nvm install --lts
nvm use --lts
npm --version
Now test it out with a dummy package:
npm install --global vaca
vaca
Since the sourcing has to be done for every new shell, you will probably want to add the following to your .bashrc
:
f="$HOME/.nvm/nvm.sh"
if [ -r "$f" ]; then
. "$f" &>'/dev/null'
nvm use --lts &>'/dev/null'
fi
Advantages:
allows you to use multiple versions of Node and without sudo
is analogous to Ruby RVM and Python Virtualenv, widely considered best practice in Ruby and Python communities
downloads a pre-compiled binary where possible, and if not it downloads the source and compiles one for you
We can easily switch node versions with:
nvm install 0.9.0
nvm install 0.9.9
nvm use 0.9.0
node --version
#v0.9.0
nvm use 0.9.9
node --version
#v0.9.9
You can then use a git tracked .nvmrc
file to indicate the node version required for a given project: https://stackoverflow.com/questions/24869959/how-do-i-specify-a-local-version-of-node-for-a-project/54503474#54503474
Tested in Ubuntu 17.10.
add a comment |
NVM (Node Version manager) with --lts
NVM was mentioned at: https://askubuntu.com/a/441527/52975 but here goes a more complete usage example, including the sane --lts
version.
NVM installs both the latest stable node and npm for you
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | sh
source ~/.nvm/nvm.sh
nvm install --lts
nvm use --lts
npm --version
Now test it out with a dummy package:
npm install --global vaca
vaca
Since the sourcing has to be done for every new shell, you will probably want to add the following to your .bashrc
:
f="$HOME/.nvm/nvm.sh"
if [ -r "$f" ]; then
. "$f" &>'/dev/null'
nvm use --lts &>'/dev/null'
fi
Advantages:
allows you to use multiple versions of Node and without sudo
is analogous to Ruby RVM and Python Virtualenv, widely considered best practice in Ruby and Python communities
downloads a pre-compiled binary where possible, and if not it downloads the source and compiles one for you
We can easily switch node versions with:
nvm install 0.9.0
nvm install 0.9.9
nvm use 0.9.0
node --version
#v0.9.0
nvm use 0.9.9
node --version
#v0.9.9
You can then use a git tracked .nvmrc
file to indicate the node version required for a given project: https://stackoverflow.com/questions/24869959/how-do-i-specify-a-local-version-of-node-for-a-project/54503474#54503474
Tested in Ubuntu 17.10.
NVM (Node Version manager) with --lts
NVM was mentioned at: https://askubuntu.com/a/441527/52975 but here goes a more complete usage example, including the sane --lts
version.
NVM installs both the latest stable node and npm for you
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | sh
source ~/.nvm/nvm.sh
nvm install --lts
nvm use --lts
npm --version
Now test it out with a dummy package:
npm install --global vaca
vaca
Since the sourcing has to be done for every new shell, you will probably want to add the following to your .bashrc
:
f="$HOME/.nvm/nvm.sh"
if [ -r "$f" ]; then
. "$f" &>'/dev/null'
nvm use --lts &>'/dev/null'
fi
Advantages:
allows you to use multiple versions of Node and without sudo
is analogous to Ruby RVM and Python Virtualenv, widely considered best practice in Ruby and Python communities
downloads a pre-compiled binary where possible, and if not it downloads the source and compiles one for you
We can easily switch node versions with:
nvm install 0.9.0
nvm install 0.9.9
nvm use 0.9.0
node --version
#v0.9.0
nvm use 0.9.9
node --version
#v0.9.9
You can then use a git tracked .nvmrc
file to indicate the node version required for a given project: https://stackoverflow.com/questions/24869959/how-do-i-specify-a-local-version-of-node-for-a-project/54503474#54503474
Tested in Ubuntu 17.10.
answered Feb 3 at 13:43
Ciro Santilli 新疆改造中心 六四事件 法轮功Ciro Santilli 新疆改造中心 六四事件 法轮功
10.3k44751
10.3k44751
add a comment |
add a comment |
If you are behind a proxy, maybe you could get this error when you run 'sudo n stable':
Error: invalid version
You have to set the env variables like this:
export HTTP_PROXY=http://your-proxy-url:port
export HTTPS_PROXY=http://your-proxy-url:port
And then run the command passing these variables to the root user:
sudo -E n stable
Credits to: github.com/tj/n/issues/430
– luandrea
Jun 8 '18 at 13:50
add a comment |
If you are behind a proxy, maybe you could get this error when you run 'sudo n stable':
Error: invalid version
You have to set the env variables like this:
export HTTP_PROXY=http://your-proxy-url:port
export HTTPS_PROXY=http://your-proxy-url:port
And then run the command passing these variables to the root user:
sudo -E n stable
Credits to: github.com/tj/n/issues/430
– luandrea
Jun 8 '18 at 13:50
add a comment |
If you are behind a proxy, maybe you could get this error when you run 'sudo n stable':
Error: invalid version
You have to set the env variables like this:
export HTTP_PROXY=http://your-proxy-url:port
export HTTPS_PROXY=http://your-proxy-url:port
And then run the command passing these variables to the root user:
sudo -E n stable
If you are behind a proxy, maybe you could get this error when you run 'sudo n stable':
Error: invalid version
You have to set the env variables like this:
export HTTP_PROXY=http://your-proxy-url:port
export HTTPS_PROXY=http://your-proxy-url:port
And then run the command passing these variables to the root user:
sudo -E n stable
answered Jun 8 '18 at 13:49
luandrealuandrea
316
316
Credits to: github.com/tj/n/issues/430
– luandrea
Jun 8 '18 at 13:50
add a comment |
Credits to: github.com/tj/n/issues/430
– luandrea
Jun 8 '18 at 13:50
Credits to: github.com/tj/n/issues/430
– luandrea
Jun 8 '18 at 13:50
Credits to: github.com/tj/n/issues/430
– luandrea
Jun 8 '18 at 13:50
add a comment |
Using nvm is preferred method. First install nvm:
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
Then install nodejs:
nvm install node
Now on, you can easy switch versions of node.
add a comment |
Using nvm is preferred method. First install nvm:
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
Then install nodejs:
nvm install node
Now on, you can easy switch versions of node.
add a comment |
Using nvm is preferred method. First install nvm:
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
Then install nodejs:
nvm install node
Now on, you can easy switch versions of node.
Using nvm is preferred method. First install nvm:
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
Then install nodejs:
nvm install node
Now on, you can easy switch versions of node.
answered Jul 18 '18 at 9:43
Damjan PavlicaDamjan Pavlica
19819
19819
add a comment |
add a comment |
protected by Community♦ Jul 4 '17 at 21:42
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?
1
It's better to use nvm to install nodejs. It stands for "Node Version Manager". You can very easily install multiple versions of nodejs, switch between them and set a default.
– Mina Michael
Nov 17 '18 at 16:11