当我尝试运行此命令 - 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)
答案 0 :(得分:0)
我已经避免使用常规方法在Mac上安装节点(主要是因为/ usr / local的权限问题),而是转而使用NVM: https://github.com/creationix/nvm
它将node和npm安装到您的主目录中,并允许您动态切换节点版本(类似于Ruby的RVM)。
我建议卸载node / npm:How do I completely uninstall Node.js, and reinstall from beginning (Mac OS X)