Questions tagged [nodejs]

Event-driven I/O server-side JavaScript environment based on V8. Includes API documentation, change-log, examples and announcements.

Node.js is a platform built on Chrome's JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.1

Installation

Node.js may be installed via three major methods on Ubuntu and its official derivatives.

Via APT

The first method is via APT (or by the front-end, the Ubuntu Software Center) by running:

sudo apt-get install nodejs

the problem, however, is that Node.js installed this way is usually very out of date.

Via APT, cURL and nodesource

Alternately, Node.js may be installed via running:

sudo apt-get install -y curl
curl -sL https://deb.nodesource.com/setup_0.12 | sudo bash -
sudo apt-get install -y nodejs

The version provided via this method is usually up to date and even when it is not it is usually only out of date by at most a few days. This installation will be automatically updated whenever one runs Software Updater.

From source

If one requires the very latest version, or another version that is not available by either of these two methods one can install from source code. This is usually the most time-consuming of methods, potentially taking over an hour, depending on one's platform, although most of this is automated requiring very little user input. To get the source code one can go to http://nodejs.org/dist/, to find a URL for the release they want (which is http://nodejs.org/dist/latest/node-$ver.tar.gz for the latest release, where $ver is replaced with the latest available version with the letter v in front of it, for example, $ver=v0.12.7 for version 0.12.7). One can then download this release from one's web browser, via , via or via whatever download manager one would prefer. For simplicity's sake the next code assumes one is downloading the tarball for Node.js version 0.5.1+ via wget, in which case the code is (run from the directory to which you want the source code downloaded):

#Install the dependencies; if you are installing Node.js 0.6.x you will also
#need libssl-dev
sudo apt-get install build-essential python
#Setting the version one is installing, remember the v!
ver=v0.12.7
wget -c http://nodejs.org/dist/$ver/node-$ver.tar.gz
tar -xzf node-$ver.tar.gz
cd node-$ver
./configure
make
sudo make install

note that at the tar line one can specify where the source code is extracted to if one wishes (via adding -C DESTDIR where DESTDIR is the destination of the source code), but if one does one will need to adjust the next line to cd DESTDIR. This installation may be more flexible than the previously-outlined methods but it will not automatically update itself. Instead to update a source installation one will need to re-run lines 5-10 with the updated ver value.

If one anticipates updating Node.js manually often (e.g., if one wants the latest release of Node.js as soon as it is released) it may be best to use instead to get the source code. Although this method will take up more hard disk drive (HDD) space and is a larger download (>100 MB), hence it is only recommended for those planning to update their Node.js installation regularly.

To get the source code via git and then install it run:

sudo apt-get install git #Installing git
git clone https://github.com/joyent/node.git
cd node
git remote add upstream https://github.com/joyent/node.git
#Again, replace this with the latest available release
ver=v0.12.7
git fetch upstream
git checkout $ver
./configure
make
sudo make install

then to update this installation re-run the last 6 lines (from ver=v0.12.7 down) of this code, with an updated ver value.

References

  1. nodejs.org
575 questions
1029
votes
16 answers

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…
Kanishka Panamaldeniya
  • 10,413
  • 3
  • 13
  • 11
223
votes
19 answers

How to install the latest versions of NodeJS and NPM?

I noticed over at the https://nodejs.org/ website that node is currently at v 0.12.0. Can someone let me know how to install the latest version of node together with npm (terminal commands please)?
tonyf
  • 2,557
  • 5
  • 15
  • 19
180
votes
16 answers

How do I install the latest version of node.js?

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?
jrg
  • 58,933
  • 52
  • 169
  • 246
148
votes
10 answers

How do you update npm to the latest version?

I'm having issues with npm in a Vagrant box I'm setting up. I noticed that the npm version is somewhat old, so I wanted to check the problem with the latest release. It is my understanding that you should be able to update npm using npm install -g…
Oliver Salzburg
  • 4,343
  • 3
  • 21
  • 33
83
votes
8 answers

Why does installing node 6.x on Ubuntu 16.04 actually install node 4.2.6?

These were my steps to install node on Ubuntu 16.04: curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash - sudo apt-get install -y nodejs sudo apt-get install -y npm which are the official…
user1063287
  • 2,175
  • 3
  • 17
  • 22
79
votes
18 answers

apt-get update failed because certificate verification failed because handshake failed on nodesource

Running sudo apt-get update on my AWS EC2 Ubuntu 18.04.01 LTS instance fails: Certificate verification failed: The certificate is NOT trusted. The certificate issuer is unknown when trying to access the deb.nodesource.com/node_10.x bionic…
Joe
  • 919
  • 1
  • 5
  • 6
61
votes
5 answers

How to install NodeJS 4 using apt?

How can I install NodeJS 4 on Ubuntu using apt-get utilities?
Kumar Sambhav
  • 741
  • 1
  • 6
  • 10
60
votes
10 answers

How to install latest node inside a docker container

How do I install the latest node inside a docker ubuntu 15.10 container? apt-get install nodejs installs version 0.1 and no npm Thanks
Tomasz
  • 1,263
  • 1
  • 9
  • 9
59
votes
4 answers

"No such file or directory" error while using npm

I installed node and npm using the instructions provided here I was able to use node successfully. However, as I attempt to install the "Formidable" node module, I get the following error: $npm install formidable bash: /usr/local/bin/npm:…
user109187
  • 1,591
  • 1
  • 10
  • 8
51
votes
7 answers

node: command not found

I don't understand why the node command will not work, whereas nodejs works: $ node --version zsh: command not found: node $ nodejs --version v0.10.15 I tried apt-get install nodejs, but the latest version is already installed. And furthermore: $…
Matthieu Napoli
  • 694
  • 2
  • 6
  • 10
43
votes
9 answers

couldn't install npm on ubuntu

Tried to install nodejs and npm on ubuntu 12.04. I googled and did it. Now, I could not install npm on machine. sudo apt-get install npm Which gives me this The following packages have unmet dependencies: npm : Depends: nodejs but it is not going…
user3297351
  • 549
  • 1
  • 4
  • 7
42
votes
5 answers

Can't install npm - Unable to correct problems, you have held broken packages?

I am trying to upgrade my nodejs to 7.6 but failed. Now I have a new problem after re-installing node 6.10: $ sudo apt-get purge nodejs npm Reading package lists... Done Building dependency tree Reading state information... Done Package 'npm'…
Run
  • 2,393
  • 9
  • 30
  • 54
36
votes
4 answers

How to resolve "service start-limit-hit"

I am trying to run a Node.js API as a service, but am running into problems. When running systemctl status servicename.service I get the following error: servicename.service - [Service description] Loaded: leaded…
Matthew
  • 493
  • 2
  • 5
  • 11
34
votes
7 answers

node.js conflicts: /sbin/node vs /usr/bin/node

I have two Ubuntu 12.10 machines: machine A is a VMWare VM and machine B is and old Acer laptop. On both machines, I installed node using apt-get. However machine A installs the main binary as /usr/bin/node and machine B as /usr/bin/nodejs. Here are…
Hai Vu
  • 491
  • 1
  • 4
  • 12
29
votes
2 answers

How can I install a tar.xz file from nodejs.org?

I'm a novice with Ubuntu. I downloaded nodejs from the nodejs.org website. The file I downloaded is node-v7.1.0-linux-x64.tar.xz I know how to extract it, but that's it. Please explain how I can install it, and where I should put it in the…
Moti Winkler
  • 393
  • 1
  • 3
  • 7
1
2 3
38 39