How do I install the latest node.js on Ubuntu? I've been looking around, and I can't find anything. Is there a Ubuntu package for node.js
, or do I have to compile it myself?
How do I install the latest node.js on Ubuntu? I've been looking around, and I can't find anything. Is there a Ubuntu package for node.js
, or do I have to compile it myself?
Per the Node.js website:
Then, you will have the latest version of Node.js.
If you're not a fan of
curl <url> | bash -
, or are using an unsupported distribution, you can try a manual installation.Node is one of the easier projects to build. Just change the version as that continues to change.
Browse to http://nodejs.org/dist/latest/ to find out the latest package version.
You should see
/usr/local/bin/node
.Yes, go to Synaptic, search for "nodejs". The packages are located in the universe repository. I suggest you install all of the packages starting with nodejs if you are doing development.
Just in case that doesn't work:
That will download the sourcecode of node.js, make it and install it.
NVM (Node Version manager)
https://github.com/creationix/nvm
Since the sourcing has to be done for every new shell, you will probably want to add the following to your
.bashrc
: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:
As this question has the word latest and NodeJS latest release version is now
v0.12.2
(as of today) and if you want to install this version you need to run following commandUpdate
NodeJS released
v5.8.0
and I still found noppa
to install yet. So I install it using NVM as followsFirst install
nvm
Then install NodeJS v5.8.0
Update 2: For those who prefer PPA ?
Generally speaking, loading arbitrary data from a URL into a root shell session is not a good idea and I wish people would stop peddling it as a solution for everything - "Please just run this script I'm sending you, and also while we're at it - I have a bridge you'd probably be interested in purchasing".
As an alternative, here's the "Ubuntu Way" of doing the same - this is basically everything the Node Source script is doing automatically, but here you can see how the system is being updated and know what repos and what keys are added to your system configuration:
This is for the latest (at time of writing) Nodejs version 7. For the LTS version (6), the repository URL you should add is
https://deb.nodesource.com/node_6.x
. Other versions can also be gotten with a simple change to the repo URL - consult nodesource.com documentation for details.Note that if you are using an alternative Ubuntu distribution such as Trisquel, the
$(lsb_release -sc)
command may not work, so you'd have to replace it with the compatible Ubuntu version name, for examplexenial
.nodejs
-package in the official repositories (15.04). Consider also usingnodejs-legacy
for thenode
command.to update to the latest version, use the
n
package installed vianpm
:See this SO question for a comparison of NVM and N.
answer for @jrg is correct, But Chris Lea's Launchpad PPA will will not be supporting
Node.js v0.12
and beyond. So to install last version forNode.js
From newnodesource PPA
according to post in nodesource Blog And joyent/nodeFirst :
This script will:
Then install
Node.js
:Update: according post in nodesource blog
To install
nodejs
version0.12.X
you nedd to run command:
To install
nodejs
version0.10.X
you nedd to run command:
Then
Install the snap package
The easiest method to install Node.js on Ubuntu is to use the snap package. Just search for node on Ubuntu Software store and install the first one.
Or if you prefer command line:
Alternate method: NVM
If you can't use snaps for some reason, like from a WSL environment, Node Version Manager (NVM) is the way to go. It's safer than upgrading the node packages in Ubuntu to unsupported versions from PPAs or 3rd party repos, which may cause conflicts or breakages in apt package management system. Compared to NVM, manual installations from tarballs are harder to maintain and upgrade. Follow these steps to install the latest node using NVM:
Install NVM
Run this command in Terminal:
Install node
Once NVM installation is complete, close and reopen Terminal. Then run this command:
Check node version
Run these commands:
If everything went well, you'll see the latest node and npm versions as output. That's all, node is installed and ready to run! ?
I am always leery of using a non-official PPA - it usually works out, but I like there to be some level of official association between the distribution channel and the project that I am using...
Personally, this is the best bang for my buck when it comes to a resource for the many good ways to install Node - https://gist.github.com/isaacs/579814