NodeJS interpreter name(node
) on Ubuntu has been renamed to nodejs
because of name conflict with another package. Here's what the readme.debian says:
The upstream name for the Node.js interpreter command is "node". In Debian the interpreter command has been changed to "nodejs".
This was done to prevent a namespace collision: other commands use the same name in their upstreams, such as ax25-node from the "node" package.
Scripts calling Node.js as a shell command must be changed to instead use the "nodejs" command.
However, using nodejs mucks up installing packages using npm
. Package installation fails with the following error:
sh: 1: node: not found npm WARN This failure might be due to the use of legacy binary "node" npm WARN For further explanations, please read /usr/share/doc/nodejs/README.Debian
How do I make npm understand that nodejs is already installed on the system but the interpreter name is different?
This is the your node is not properly install, first you need to uninstall the node then install again. To install the node this may help you http://array151.com/blog/nodejs-tutorial-and-set-up/
after that you can install the packages easily. To install the packages this may help you
http://array151.com/blog/npm-node-package-manager/
Try linking node to nodejs. First find out where nodejs is
Then soft link node to nodejs
I am assuming /usr/bin is in your execution path. Then you can test by typing node or npm into your command line, and everything should work now.
For me the fix was removing the node* packages and also the npm packages.
Then a fresh install as:
Install
nvm
first using:Run command
Now run this and this will show will all installed or other versions of packages:
Installed packages will be in green. Install whatever version you want:
Check where is not installed:
Check current version:
TL;DR:
First of all let me clarify the situation a bit. In summer 2012 Debian maintainers decided to rename Node.js executable to prevent some kind of namespace collision with another package. It was very hard decision for Debian Technical Committee, because it breaks backward compatibility.
The following is a quote from Committee resolution draft, published in Debian mailing list:
Paragraph 2 is the actual solution for OP's issue. OP should try to install this package instead of doing symlink by hand. Here is a link to this package in Debian package index website.
It can be installed using
sudo apt-get install nodejs-legacy
.I have not found any information about adopting the whole thing by NPM developers, but I think
npm
package will be fixed on some point andnodejs-legacy
become really legacy.