Node.js is not a first class citizen in Debian yet. Installing it is easy but not entirely straight forward.
Update 2015/05/10: Jessie is the new Debian Stable and Node.js has much better support for it. Here are their instructions for installation.
Update 2015/04/13: The curl instruction has been updated according to the NPM documentation.
Update 2014/10/27: The nodejs package is now only available in backports for Wheezy (Stable), but is in Jessie (Testing) and Sid (Unstable). Follow the instructions in this post to install wheezy-backports.
We can install Node.js with the following command (for best results run all these commands as root):
# aptitude -t wheezy-backports install nodejs
‘-t wheezy-backports’ can be left out if you are using a newer release than Wheezy/Stable.
This will install Node.js, but as the command nodejs, not node as per normal. You can stop here, if all you intend to do is run Node.js and can remember that it is now called nodejs. But if you want to install NPM you need to continue.
First we want to be able to use the command node (if only because the NPM install expects it), to do this we use Debian’s update-alternatives command:
# update-alternatives --install /usr/bin/node nodejs /usr/bin/nodejs 100
Finally we can install NPM. It is not in installed with Node.js nor does it seem to be in the repositories, so we need to install it like so:
# curl https://www.npmjs.com/install.sh | sh
You can test your install with the following commands:
# node -v
# npm -v
Thank you so much for posting these instructions. I just spent three hours using instructions on github where it states “npm comes with node now.” I met partial success changing node to nodejs in install.sh and then was stuck while the “man” files were being built.
Pleasure, glad to be of help.
Meanwhile update-alternatives is not necessary anymore, as in wheezy-backports the package nodejs-legacy is available, which brings the node binary :_)
You’re the man DUDE! Thanks.
hi there,
in jessie nodejs and npm both are installed. See
$ nodejs -v
v0.10.29
$ npm -v
1.4.21
# node -v
v0.10.28
npm -v
2.1.2
Oh,this is successful advice,thx
Thanks!
Next warnings during installing NPM:
cleanup prefix=/usr
find: `/usr/lib/node’: No such file or directory
find: `/usr/lib/node’: No such file or directory
I’m on Debian 7.7, and I can guarantee that nodejs is not in the repository.
Thanks “Nope”. I have updated the article to explain that nodejs is now only available in backports on Wheezy / Stable.
Also you can install with follow:
apt-get install curl
curl -sL https://deb.nodesource.com/setup | bash –
apt-get install nodejs
I am getting this error and no file is downloaded. Any idea why?
$ sudo curl https://www.npmjs.org/install.sh | sudo sh
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 51 100 51 0 0 1146 0 –:–:– –:–:– –:–:– 1821
sh: 1: Moved: not found
If you hit the “Move: not found” error, use the -L option in curl to allow it to follow any redirection.
$curl -L https://www.npmjs.org/install.sh | sudo sh
Or use the updated URL:
curl https://www.npmjs.com/install.sh | sudo sh
I get same error.
Trouble in line
# curl https://www.npmjs.org/install.sh | sudo sh
Use (by root of cource)
# curl -L https://npmjs.org/install.sh | sh
instead. It is from official npm-site and it work.
Ran into some problem: this worked instead:
curl -L https://npmjs.org/install.sh | sudo sh
# node -v
v0.10.29
# npm -v
2.7.6
Worked perfectly, as charm!
Thank you!
Hi. I followed the steps but got stuck on running
‘aptitude -t wheezy-backports install nodejs’
but I get this error:
No candidate version found for nodejs
Is there something I missed?
(I am using debian wheezy 7.8)
maybe you do not add ‘wheezy backports’ repository in /etc/apt/sources.list or do not run ‘apt-get update’ after previous action. so check it.
run
$ sudo nano /etc/apt/sources.list
and put there the line (if it not exist yet):
deb http://http.debian.net/debian wheezy-backports main
save, exit, and type in terminal
$ sudo apt-get update
and finally
$ sudo apt-get -t wheezy-backports install nodejs
Installed on Deepin Linux based Jessie, this save my Odoo 9 and works now like a charm.
# curl https://www.npmjs.org/install.sh | sudo sh
# curl -L https://npmjs.org/install.sh | sh
works like a charm.
if using Odoo 9 , don’t forget to upgrade workzeug doing
# pip install –upgrade pip
# pip install –upgrade werkzeug
I want nodejs v5.5.0 and NPM v3.3.12
how to update from 5.0.0 to v5.5.0
for debian 7
on my side, It almost worked but I got this:
curl https://www.npmjs.com/install.sh | clean=yes sh
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 6263 100 6263 0 0 7958 0 –:–:– –:–:– –:–:– 8176
tar=/bin/tar
version:
tar (GNU tar) 1.26
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later .
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by John Gilmore and Jay Fenlason.
install npm@latest
fetching: https://registry.npmjs.org/npm/-/npm-4.6.1.tgz
npm ERR! Object function (err) {
npm ERR! if (err) return cb(err)
npm ERR! fs.fsync(fd, function (err) {
npm ERR! if (err) return cb(err)
npm ERR! fs.close(fd, cb)
npm ERR! })
npm ERR! } has no method ‘toLowerCase’
It failed
So in the end, it fails, but I just don’t know what to do, any idea?
Thanks