Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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 some behaviors I observed:

  1. Both machine returns /usr/bin/node in response to the which node command. However, there is no such file on machine B.
  2. Issuing the command node works for machine A, not B. On B, I have to use nodejs instead.
  3. On B, there is a binary called /sbin/node, A does not have it.

These behaviors causes inconsistency problem when developing on both machines. For now, I worked around by renaming the binaries on B as such:

sudo mv /sbin/node /sbin/node-sbin
sudo ln -s /usr/bin/nodejs /usr/bin/node

Is there a way to really fix this, so that node will be installed as /usr/bin/node instead of /usr/bin/nodejs?

share|improve this question
add comment

4 Answers

up vote 1 down vote accepted

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.

share|improve this answer
    
This is it. Thank you. –  Hai Vu Mar 29 at 21:31
add comment

Try completely removing the conflicting node package:

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

# 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.

share|improve this answer
    
Thank you for the background info. At this point, I don't have any of these machines to try on, but I hope I can revisit some day soon. –  Hai Vu Jul 15 '13 at 15:41
    
This doesn't get you a /usr/bin/node in Ubuntu 13.10. @user229115's answer below works, though. –  Jim Stewart Jan 26 at 7:42
    
So with Ubuntu 13.10 sudo apt-get install nodejs nodejs-legacy will give you the node binary as node.js But if you already installed the node (Amateur Packet Radio Node Program) you'll obviously need to remove it. –  jonasfj Feb 20 at 4:03
add comment

Unfortunately for me, creating a symlink did not work. What did work for me though was creating an alias. In ~/.bashrc or ~/.bash_aliases (if ~/.bashrc loads this file), just add the following line:

alias node="nodejs"

Restart your bash session by typing bash into the console and your alias will now work.

share|improve this answer
2  
When I created a symlink, it did not work until I started another terminal. Try restarting your terminal... or my answer that works without symlinks/aliases ^^ –  Leftium Jul 16 '13 at 22:36
add comment

I think this is it:

sudo update-alternatives --install /usr/bin/node node /usr/bin/nodejs 10

Using Debian alternatives.

share|improve this answer
    
Thanks. This is the most direct way to remedy Ubuntu's decision on this matter. –  Drew 2 days ago
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.