Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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

$ which npm
/usr/local/bin/npm
$ npm
bash: /home/steven/local/bin/npm: No such file or directory
$ echo $PATH
/home/steven/local/bin:/home/steven/local/bin:/home/steven/local/bin:/home/steven/local/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
$ 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
add comment

2 Answers 2

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
add comment

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

PATH=/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/steven/local/bin:/home/steven/local/bin:/home/steven/local/bin:/home/steven/local/bin

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
add comment

Your Answer

 
discard

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.