NPM:在OS X上升级到Node.js 5.0之后找不到模块'./lib'(NPM: cannot find module './lib' after upg

编程入门 行业动态 更新时间:2024-10-28 11:32:29
NPM:在OS X上升级到Node.js 5.0之后找不到模块'./lib'(NPM: cannot find module './lib' after upgrading to Node.js 5.0 on OS X)

背景

我刚从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.0

Other 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.

更多推荐

本文发布于:2023-08-07 00:19:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1457964.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:找不到   升级到   模块   js   NPM

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!