Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I installed node and npm using the instructions provided here

I was able to use node successfully. However, as I attempt to install the "Formidable" node module, I get the following error:

$npm install formidable
bash: /usr/local/bin/npm: /usr/local/bin/node: bad interpreter: No such file or directory

When I do a which npm I get the following output:

$which npm

I have no clue on what is wrong with npm here - any idea on how I can fix this?

share|improve this question
Welcome to Ask Ubuntu! I see you've installed Node in /usr/local/bin/. The packages as you used in the instructions you linked to don't do this. I think you've installed another Node from source as well. Please tell the whole story. – gertvdijk Feb 3 '13 at 21:54
@gertvdijk Well, there was node 0.8.14 installed initially. I wanted to upgrade this to 0.8.18. I then ran $sudo apt-get remove --purge nodejs npm but this did not work. node --version after installing 0.8.18 still showed 0.8.14. So, what I did was follow a post which I can't find now - it basically instructed to do which node followed by rm -r /usr/local/bin/... - basically some node related files under that directory. Now, after this, i re-installed node and it was the updated version. Its working fine, but npm isn't. – user109187 Feb 4 '13 at 15:06
Yeah this is what happens when you install from source. It will confuse your package management and you as a user. Please only install software as packages unless you know what you're doing. Use the uninstall instructions with the scripts you used to install this earlier version to properly uninstall it. And please edit your question to provide further information. This is a Q&A site, not a discussion forum, you see? :) – gertvdijk Feb 4 '13 at 15:07
@gertvdijk I found the post which instructed to manually remove the files - The path here is /usr/bin/node – user109187 Feb 4 '13 at 15:08
up vote 17 down vote accepted

Taking @gertvdijk hint, I uninstalled npm using the script:

rm -rf /usr/local/{lib/node{,/.npm,_modules},bin,share/man}/npm*

which can be found here -

Even after performing the above, I got another error:

$npm install formidable
bash: /usr/local/bin/npm: No such file or directory

So, I $ hash -r in the terminal (as per the instructions found under and voila - it worked. npm now works!

share|improve this answer
thanks! worked like a charm – gion_13 Aug 20 '13 at 7:32
the only useful thing here was discovering hash, which can be simply used to point to another node/npm (what if I wish to work with more than one version of node?) – user309383 May 25 at 20:55

Ubuntu and some Linux distributions install node's interpreter as /usr/bin/nodejs, and not /usr/local/bin/node.

You can solve this issue installing the nodejs-legacy package which creates a symlink from /usr/bin/nodejs to /usr/bin/node.


sudo apt-get install nodejs-legacy

References: nodejs-legacy package

share|improve this answer

It appears that you've installed another Node version from source some time earlier. This is indicated by the /usr/local/bin path where it appears to be installed now.

  1. Uninstall the one you installed from source. See the instructions that got with the source on how to do so. There's no single way on how to uninstall software scripts installed which don't work with your system's package management.
  2. Install the packages with are listed in the instructions you linked to in your question.
  3. Verify that which npm now lists /usr/bin as installation path.

In general you should never have to install packages from source. And if you do, please be aware of the consequences as you're overriding the package management here an it will get confused by it.

share|improve this answer

Your Answer


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.