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?
As other folks already mention, I will suggest not to use "sudo apt-get" to install node or any development library. You can download required version from https://nodejs.org/dist/v6.9.2/ and setup you own environment.
I will recommend tools like nvm and n, to manage you node version. It is very convenient to switch and work with these modules. https://github.com/creationix/nvm https://github.com/tj/n
Or write basic bash to download zip/tar, extract move folder and create a soft link. Whenever you need to update, just point the old soft link to new downloaded version. Like I have created for my own, you can refer: https://github.com/deepakshrma/NodeJs-4.0-Reference-Guide/blob/master/nodejs-installer.sh
Your System is not able to detect the path node js binary.
1.which node
2.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.
you can create a link
ln -s nodejs
node in/usr/bin
hope this solves your problem.Problem is not in installer
replace nodejs with node or change the path from /usr/bin/nodejs to /usr/bin/node
You can also install Nodejs using NVM or Nodejs Version Manager There are a lot of benefits to using a version manager. One of them being you don't have to worry about this issue.
Instructions:
Once the prerequisite packages are installed, you can pull down the nvm installation script from the project's GitHub page. The version number may be different, but in general, you can download and install it with the following syntax:
This will download the script and run it. It will install the software into a subdirectory of your home directory at
~/.nvm
. It will also add the necessary lines to your~/.profile
file to use the file.To gain access to the nvm functionality, you'll need to log out and log back in again, or you can source the ~/.profile file so that your current session knows about the changes:
Now that you have nvm installed, you can install isolated Node.js versions.
To find out the versions of Node.js that are available for installation, you can type:
As you can see, the newest version at the time of this writing is v0.11.14. You can install that by typing:
Usually, nvm will switch to use the most recently installed version. You can explicitly tell nvm to use the version we just downloaded by typing:
When you install Node.js using nvm, the executable is called node. You can see the version currently being used by the shell by typing:
The comeplete tutorial can be found here
Uninstall whatever node version you have
install nvm (Node Version Manager) https://github.com/creationix/nvm
Now you can install whatever version of node you want and switch between the versions.