Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm running an Amazon Linux AMI and successfully installed node.js by wget'ing the source, untarring the file, and running ./configure and then sudo make install. When I installed npm:

curl http://npmjs.org/install.sh | sudo sh

It outputs:

npm cannot be installed without nodejs.
Install node first, and then try again.

Maybe node is installed, but not in the PATH?
Note that running as sudo can change envs.

PATH=/sbin:/bin:/usr/sbin:/usr/bin

But node is clearly installed (running node -v shows its version), so it must be that node is not in my path.

I open ~/.bash_profile and add this line:

export PATH=/usr/local/bin:$PATH

Then run source ~/.bash_profile

and try to install npm again, only to find that it outputs the same message as last time, which the exact same PATH.

Then, the weird thing is that I notice that npm is actually installed! Running npm -v shows its version. Hm....

Then I run npm install supervisor in the directory of my app, and the supervisor folder is there in /node_modules, however the supervisor command does not exist.

Installing supervisor outputs:

npm WARN prefer global supervisor@0.3.1 should be installed with -g

so I try npm install -g supervisor which outputs

npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules/supervisor'
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

so I try sudo npm install -g supervisor

but the output is sudo: npm: command not found

So to sum up, npm seems to be working fine, although the output when installing it would lead one to believe otherwise, and the supervisor package seems like it's installed, but its command is not working.

Any help on figuring this out would be greatly appreciated!

share|improve this question
    
I'd highly recommend installing node and npm using yum (as per the docs): sudo yum localinstall --nogpgcheck http://nodejs.tchol.org/repocfg/amzn1/nodejs-stable-release.noarch.rpm and sudo yum install nodejs-compat-symlinks npm. In addition to keeping things up to date, it tends to avoid a lot of the problems encountered when compiling from source. –  cyberx86 May 22 '12 at 2:09
    
@cyberx86 just uninstalled node and reinstalled with yum. Node works, but npm doesn't seem to exist? –  Justin Meltzer May 22 '12 at 2:41
    
If it was installed, it should be in /usr/bin/npm which is a symlink to /usr/lib/nodejs/npm/bin/npm-cli.js. Can you confirm that npm is in fact installed? (I use Amazon Linux and node.js/npm so I can confirm that it should work.) –  cyberx86 May 22 '12 at 2:45
    
@cyberx86 /usr/bin/npm does exist, and so does /usr/lib/nodejs/npm/bin/npm-cli.js. Running npm -v returns -bash: /usr/local/bin/npm: No such file or directory –  Justin Meltzer May 22 '12 at 2:51
    
@cyberx86 and adding /usr/bin to my path gets npm working! :) –  Justin Meltzer May 22 '12 at 2:54
show 6 more comments

1 Answer

up vote 3 down vote accepted

When possible, it is best to avoid compiling packages. In addition to often installing in non-standard locations, software that is compiled from source is much harder to keep up to date. Node.js provides a procedure to install from a repository - which includes npm and some other related components. The repository is kept up to date and is rarely more than a couple of days behind the source code. Moreover, instructions are available for Amazon Linux specifically:

sudo yum localinstall --nogpgcheck http://nodejs.tchol.org/repocfg/amzn1/nodejs-stable-release.noarch.rpm
sudo yum install nodejs-compat-symlinks npm.

npm should install to /usr/bin/npm which is a symlink to /usr/lib/nodejs/npm/bin/npm-cli.js. Of course, with some of the modifications made to your PATH, it is possible that npm may not be found. echo $PATH (as root) should resemble:

/usr/local/sbin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/aws/bin:/root/bin

One of the common problems when previous installs with npm fail is a corrupted cache - clear your npm cache (npm cache clear) and see if you have any success. Of course, installing a package globally, needs to be done as root.

share|improve this answer
2  
As at Aug/13 the packages on nodejs-tchol.org appear to be unmaintained. They're 2 months and a major version number out of date. –  Socio Aug 13 '12 at 13:29
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.