Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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

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...

share|improve this question

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.

share|improve this answer
"does not share bash's cache" – daniel kullmann Nov 19 '11 at 2:36
@danielkullmann Oops, thanks – Gilles Nov 19 '11 at 2:38

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).

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.