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

Solution 1:

update: modified instructions below to use the nodejs-legacy package.(more info about node-legacy)

Try completely removing the conflicting node package:

sudo apt-get --purge remove node
sudo apt-get --purge remove nodejs-legacy
sudo apt-get --purge remove nodejs

sudo apt-get install nodejs-legacy

# Confirm it worked
node --version       # v0.10.13
ls -la `which node`  # ... /usr/bin/node -> /etc/alternatives/node

This happened to me when I unwittingly installed the non-node.js node package. Although I did apt-get remove node before installing the correct nodejs package, I guess the --purge argument is required.

Background info:

There is a naming conflict with the node package (Amateur Packet Radio Node Program), and the nodejs binary has been renamed from node to nodejs. You'll need to symlink /usr/bin/node to /usr/bin/nodejs or you could uninstall the Amateur Packet Radio Node Program to avoid that conflict.

Solution 2:

On Ubuntu 13.10 all answers above did not work for me. It finally worked when I installed nodejs-legacy

sudo apt-get install nodejs-legacy

This correctly provided /usr/bin/node for me, so that e. g. nodemon can be used.