使用OSX El Capitan安装节点5.0.0后的npm mulfunction

时间:2015-11-17 13:40:41

标签: node.js macos npm

任何npm命令(npm -v除外,即3.3.6)都会返回如下内容:

Error: Cannot find module './lib'
    at Function.Module._resolveFilename (module.js:337:15)
    at Function.Module._load (module.js:287:25)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/request/node_modules/hawk/index.js:1:80)
    at Module._compile (module.js:425:26)
    at Object.Module._extensions..js (module.js:432:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
npm ERR! Darwin 15.0.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm"
npm ERR! node v5.0.0
npm ERR! npm  v3.3.6
npm ERR! code MODULE_NOT_FOUND

npm ERR! Cannot find module './lib'
npm ERR! 
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

有谁知道解决方案?

1 个答案:

答案 0 :(得分:2)

你需要完全删除npm(卸载nodejs并在没有npm的情况下安装它) 然后使用 curl -L https://www.npmjs.com/install.sh | sh

这是一个说明 https://gist.github.com/DanHerbert/9520689