简体   繁体   English

无法在Mac上安装NPM

[英]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 当我尝试运行此命令npm -v ,在mac命令行上得到以下废话

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 我避免使用常规方法在Mac上安装节点(主要是由于/ usr / local的权限问题),而改用了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). 它将节点和npm安装到您的主目录中,并允许您即时切换节点的版本(类似于Ruby的RVM)。

And I'd suggest uninstalling node/npm: How do I completely uninstall Node.js, and reinstall from beginning (Mac OS X) 我建议卸载node / npm: 如何完全卸载Node.js,然后从头开始重新安装(Mac OS X)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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