Node.js installieren (Ubuntu)

9. November 2013 / JS / Node.js / Ubuntu

×Info: This post is older than 2 years! Displayed information may be outdated!

Mehrere Wege führen zum Ziel, wenn man Node.js unter Ubuntu installieren will.

Weg 1: Installation via apt

ACHTUNG: Je nachdem ist die Version von Node.js in den Paketquellen recht alt.

# apt-get
sudo apt-get update && sudo apt-get install nodejs

Weg 2: Installation über PPA

Aus der Doku:

# PPA adden, dann installieren
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install python-software-properties python g++ make nodejs

Weg 3: Build from source

Der spassige Teil! Ebenfalls aus der Doku:

sudo apt-get install python g++ make checkinstall
mkdir ~/src && cd $_
wget -N http://nodejs.org/dist/node-latest.tar.gz
tar xzvf node-latest.tar.gz && cd node-v*
./configure
sudo checkinstall -y --install=no --pkgversion 0.10.24  # Replace with current version number.

# optionally append " -- make -jx install" to the previous line and replace x with number of cores.

# then install
sudo dpkg -i node_*

# uninstall (if something went "wrong"...)
sudo dpkg -r node

Weitere Schritte: Installation NPM, Grunt, Troubleshooting

Egal welchen Weg man wählt, es gibt noch einiges zu tun:

# npm installieren
sudo apt-get install npm

# grunt installieren
sudo npm install -g grunt-cli

# Symlink setzen unter Ubuntu (sonst gibts Fehler)
sudo ln -s /usr/bin/nodejs /usr/bin/node

Tipps & Tricks

# npm cache leeren
npm cache clean

Wenn ein auto-Install (npm install) failt:

  • checken, ob /user/name/tmp dem user gehört, notfalls rekursiv chownen
  • Modul von Hand installieren: „npm install modulname“