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 am on Mac OS X Lion, I just used the package installer from nodejs.org to install node.js. Node.js is working fine, and Node.js comes with npm. I have homebrew installed as well. I am just trying to install coffeescript, but the terminal keeps throwing an error. So i decieded to check what version of npm I am running. It just keeps throwing an error. Whenever i try to use any npm command, it throws the same error. I tried to just install npm seperately and I get and error, and same thing when i try to remove npm. Can anyone please help, this is so unbelievably frustrating.

Error when i call npm help

macbook-air:~ mcbeav$ sudo npm help

node.js:201
        throw e; // process.nextTick error, or 'error' event on first tick
              ^
Error: No such module
    at Object.<anonymous> (/usr/lib/node_modules/npm/lib/utils/config-defs.js:5:21)
    at Module._compile (module.js:441:26)
    at Object..js (module.js:459:10)
    at Module.load (module.js:348:31)
    at Function._load (module.js:308:12)
    at Module.require (module.js:354:17)
    at require (module.js:370:17)
    at Object.<anonymous> (/usr/lib/node_modules/npm/lib/utils/ini.js:43:18)
    at Module._compile (module.js:441:26)
    at Object..js (module.js:459:10)
macbook-air:~ mcbeav$ 

error when i try to install npm through the terminal

All clean!

npm ERR! Error: EPERM, chmod '/usr/local/bin/npm'
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.
npm ERR! 
npm ERR! System Darwin 11.3.0
npm ERR! command "/usr/local/bin/node" "/private/var/folders/g1/tn_gpxcj423d1dn_jx2g9gp40000gn/T/npm.1064/package/cli.js" "rm" "npm" "-gf"
npm ERR! cwd /private/var/folders/g1/tn_gpxcj423d1dn_jx2g9gp40000gn/T/npm.1064/package
npm ERR! node -v v0.6.17
npm ERR! npm -v 1.1.21
npm ERR! path /usr/local/bin/npm
npm ERR! code EPERM
npm ERR! message EPERM, chmod '/usr/local/bin/npm'
npm ERR! errno {}
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /private/var/folders/g1/tn_gpxcj423d1dn_jx2g9gp40000gn/T/npm.1064/package/npm-debug.log
npm not ok
npm ERR! error rolling back npm@1.1.21 Error: EPERM, chmod '/usr/local/bin/npm'

npm ERR! Error: EPERM, chmod '/usr/local/bin/npm'
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.
npm ERR! 
npm ERR! System Darwin 11.3.0
npm ERR! command "/usr/local/bin/node" "/private/var/folders/g1/tn_gpxcj423d1dn_jx2g9gp40000gn/T/npm.1064/package/cli.js" "install" "-gf"
npm ERR! cwd /private/var/folders/g1/tn_gpxcj423d1dn_jx2g9gp40000gn/T/npm.1064/package
npm ERR! node -v v0.6.17
npm ERR! npm -v 1.1.21
npm ERR! path /usr/local/bin/npm
npm ERR! code EPERM
npm ERR! message EPERM, chmod '/usr/local/bin/npm'
npm ERR! errno {}
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /private/var/folders/g1/tn_gpxcj423d1dn_jx2g9gp40000gn/T/npm.1064/package/npm-debug.log
npm not ok
It failed
macbook-air:~ mcbeav$ 

Error when i try to remove npm

macbook-air:~ mcbeav$ sudo npm uninstall npm -g

node.js:201
        throw e; // process.nextTick error, or 'error' event on first tick
              ^
    Error: No such module
        at Object.<anonymous> (/usr/lib/node_modules/npm/lib/utils/config-defs.js:5:21)
        at Module._compile (module.js:441:26)
        at Object..js (module.js:459:10)
        at Module.load (module.js:348:31)
        at Function._load (module.js:308:12)
        at Module.require (module.js:354:17)
        at require (module.js:370:17)
        at Object.<anonymous> (/usr/lib/node_modules/npm/lib/utils/ini.js:43:18)
        at Module._compile (module.js:441:26)
        at Object..js (module.js:459:10)
    macbook-air:~ mcbeav$ 
share|improve this question
    
Have you tried the chmod from an actual root shell? –  rackandboneman May 9 '12 at 23:28
    
to be honest, I am not extremely familiar with the terminal, so no. any chance you might be able to give me a little guidance? –  mcbeav May 10 '12 at 0:25
    
It should be possible to activate a true root account (for heavens sake put a good password on it!) on Mac OSX by executing "sudo passwd root", which should the allow you to "su -". YMMV on Lion, and care is advised using it. –  rackandboneman May 10 '12 at 14:40
add comment

1 Answer 1

up vote 0 down vote accepted

It turns out an old installation was conflicting with the new one. The old was stored in

usr/bin

where the new was stored in

usr/local/bin

i had to install it using the command

curl http://npmjs.org/install.sh | sudo clean=yes sh

and it worked fine, for anyone else having the same issue, very frustrating

share|improve this answer
    
I'm running into this same issue, but doing a clean install doesn't seem to help and it still looking for nmp in usr/bin. I tried a hash -r hearing that that might help, but still no luck. Any other advice on how I might clear out that old npm? –  nicholas Dec 31 '12 at 13:33
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.