简体   繁体   中英

Unable to install npm on mac

When I try to run this command -- npm -v , I get the following crap on the mac command line

node.js:134
        throw e; // process.nextTick error, or 'error' event on first tick
        ^
TypeError: Cannot call method 'apply' of undefined
    at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npmlog/log.js:63:25)
    at EventEmitter.log (native)
    at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npmlog/log.js:137:21)
    at EventEmitter.info (native)
    at /usr/local/lib/node_modules/npm/bin/npm-cli.js:20:5
    at Object.<anonymous> (/usr/local/lib/node_modules/npm/bin/npm-cli.js:86:2)
    at Module._compile (module.js:404:26)
    at Object..js (module.js:410:10)
    at Module.load (module.js:336:31)
    at Function._load (module.js:297:12)

I've avoided installing node on a Mac using the normal methods (mostly because of the permission issues with /usr/local), and instead switched to using NVM: https://github.com/creationix/nvm

It'll install node and npm into your home directory, and allow you to switch versions of node on the fly (similar to RVM for Ruby).

And I'd suggest uninstalling node/npm: How do I completely uninstall Node.js, and reinstall from beginning (Mac OS X)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM