I successfully update/install the latest version of node js by using those commands (the official curl way not working for me) :

sudo npm cache clean -f
sudo npm install -g n
sudo n stable

sudo ln -sf /usr/local/n/versions/node/<VERSION>/bin/node /usr/bin/node

However, the version of my node and nodejs become different :

$ node --version
$ nodejs --version

It seems the new node is installed in /usr/local/bin/node, so i tried :

sudo ln -s /usr/bin/nodejs /usr/local/bin/node

But it returns :

ln: failed to create symbolic link ‘/usr/local/bin/node’: File exists

I also use this link :

$ sudo ln -s /usr/bin/nodejs /usr/bin/node
ln: failed to create symbolic link ‘/usr/bin/node’: File exists

I will use some frameworks that depend on node, like Ionic. Which node version will it use?

What should i do to solve this?

Thanks a lot for your help

  • The real question imo is, how do I tell n to overwrite any existing node versions and symlink both nodejs and node to the binary installed by n. And if n is incapable of doing so, what is the state of the art approach? In a working environment it is very prone to error, if nodejs and node address different nodejs versions. – atripes Jan 30 '17 at 10:04

Steps that solved the same problem for me:

sudo apt-get remove nodejs
sudo ln -s /usr/bin/node /usr/bin/nodejs


You have installed two versions of nodejs on your computer, so you need to remove one of them. Your situation:

node v5.0.0 - you will keep this one
nodejs v0.10.25 - this you can remove

You can remove nodejs package via apt-get remove command. This will also remove the file /usr/bin/nodejs and you will not get your error message again.

Now you can create a symbolic link called "/usr/bin/nodejs", that points on source "/usr/local/bin/node". In your example you have wrong order of paths "from" and "to"

sudo ln -s source_file myfile

More info about links creation: How symbolic links works


The error:

ln: failed to create symbolic link ‘/usr/bin/node’: File exists

is normally caused when you really have two versions of the Nodejs, a with the alias of the node and the other with the nodejs alias, as we can see on the result of the commands node --version and nodejs --version:

$ node --version
$ nodejs --version

so you can't create a symbolic link for a file that already exists.

To solve this you need to completely remove the two packages using:

sudo apt-get purge node
sudo apt-get purge nodejs
sudo rm -rf bin/node bin/node-waf include/node lib/node lib/pkgconfig/nodejs.pc share/man/man1/node

and reinstall only the nodejs package using the command:

sudo apt-get install nodejs

and create a symbolic link using:

ln -s /usr/bin/nodejs /usr/bin/node

or install the nodejs-legacy that will resolve this problem with the command:

sudo apt-get install nodejs-legacy 
  • thanks a lot, you added the information, I already solved the issue by myself. I upvoted. – areim Jan 18 '16 at 15:42

For me the node command is the NodeJS installed by nvm and nodejs command is the NodeJS installed using apt-get

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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