Sam Munroe
Sam Munroe

Reputation: 1418

Npm and Node commands are broken

Every time I try and run npm -v or node -v I get:

/usr/bin/env: node: No such file or directory

This is my /usr/local/bin/

-rwxr-xr-x  1 root root     492 Jun 13 15:23 bundle
-rwxr-xr-x  1 root root     493 Jun 13 15:23 bundler
-rwxr-xr-x. 1 root root    2774 Jan 25  2015 charm
-rwxr-xr-x  1 root root 1116534 Aug  7  2015 composer
-rwxr-xr-x  1 root root    2777 Jul 23  2015 mine
lrwxrwxrwx  1 root root      15 Oct 13 14:44 node -> /usr/bin/nodejs
lrwxrwxrwx  1 root root      38 Oct 13 14:53 npm -> ../lib/node_modules/npm/bin/npm-cli.js
lrwxrwxrwx  1 root root      20 Jan 21  2016 packettracer -> /opt/pt/packettracer
-rwxr-xr-x. 1 root root    2580 Jan 25  2015 pstorm
-rwxr-xr-x  1 root root  255192 Apr 11  2016 rdesktop
-rw-r--r--  1 root root     165 Jan 27  2015 subl
-rwxr-xr-x  1 root root  193370 Aug  7  2015 symfony

If I navigate to the following directory, I can see npm and node in there and I can check the versions without error

/usr/local/n/versions/node/6.6.0/bin 

Also when I try and run sudo yum install nodejs, it tells me it's already installed and that i'm running an older version. This all happened after I recently updated node and npm.

Upvotes: 1

Views: 2041

Answers (1)

mattdm
mattdm

Reputation: 2301

It seems very likely that this didn't work because the node binary is in /usr/local/n/versions/node/6.6.0/bin (as you say) and that isn't in the PATH environment variable. By default, this is set to some of the standard locations for binaries, and this isn't one of those, so env has no idea where to look. See https://unix.stackexchange.com/questions/26047/how-to-correctly-add-a-path-to-path for more on setting this.

Upvotes: 1

Related Questions