背景
我刚从Mac上的Node.js v4.1.1升级到v5.0.0。 我使用节点网站上的node-v5.0.0.pkg安装程序,因为我没有安装nvm或n ,而且我没有通过Homebrew或MacPorts安装。
问题
现在,每次运行npm ,我的终端都会出现以下错误:
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 14.5.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>Background
I just upgraded from Node.js v4.1.1 to v5.0.0 on my Mac. I used the node-v5.0.0.pkg installer from the node website because I don't have nvm or n installed, and I didn't install through Homebrew or MacPorts).
Problem
Now, every time I run npm I get the following error in my terminal:
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 14.5.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>I can't even re-install NPM through the traditional method of running npm install -g npm because the package manager itself doesn't work.
How do I get NPM working again on my Mac?
最满意答案
解:
rm -rf /usr/local/lib/node_modules/npm 重新安装节点js v5.0.0其他说明:看起来其他人正在遇到同样的问题(参见问题#3606 )。 听起来好像修复工作正在进行中,因此这个问题可能会在下一个版本中得到解决。 在此期间,唯一的解决方案是从系统中彻底清除npm并重新安装。
Solution:
rm -rf /usr/local/lib/node_modules/npm Reinstall node js v5.0.0Other notes: Looks like other people are running in to the same problem (see issue #3606). It sounds like a fix is in the works, so this issue will probably be resolved in the next release. In the interim, the only solution is to completely purge npm from your system and reinstall.
更多推荐
发布评论