This time I ran the "trusting" install script curl http://npmjs.org/install.sh | sudo sh from the dir /.

$ which npm
$ npm
bash: /home/steven/local/bin/npm: No such file or directory
$ echo $PATH
$ ls /home/steven/local/bin
node  node-waf
$ ls /usr/local/bin
node  node-waf  npm  npm_g  npm-g

It seems like some script somewhere is polluting my $PATH. What I wonder is, if bash can't find the program in the first dir it looks in, doesn't it keep looking through $PATH? It should be able to find it in /usr/local/bin!

npm really, really doesn't seem to want to just work. I think I'm gonna go load up a slightly older Ubuntu and give this another go...


Chances are that you did have a /usr/local/bin/npm and your shell remembers it in its cache. You can clear the cache with hash -d npm. The cache is not shared within shell instances, so the problem will not last.

The reason the output of which is inconsistent with what your shell does is that which is an external program, so it does not share bash's cache. Use type instead, it's a shell built-in so it's more reliable.


You can consider yourself rather lucky, because you've just learned the easy way, that you should not put your additional binary dirs in front of the PATH variable. A sane PATH variable in your case should look something like


But the problem that actually caused your error is not really with PATH, rather with what npm command has probably been aliased to. To learn that, type

type npm

Another option could be that /usr/local/bin/npm is just a broken symlink to /home/steven/local/bin/npm (but you'd learn that with the above command also).

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.