简体   繁体   English

npm:“找不到模块内部/错误”

[英]npm: “Cannot find module internal/errors”

On a MacBook with the latest version of NodeJS, I am trying to update npm: 在具有最新版本NodeJS的MacBook上,我正在尝试更新npm:

npm install npm@latest

The error message is: 错误消息是:

npm ERR: code MODULE_NOT_FOUND
npm ERR: Cannot find module 'internal/errors'
npm ERR: A complete log of this run can be found in:
npm ERR:     /Users/alexander/.npm/_logs/2017_09_15_12_35_47_079Z-debug.log

and the referenced log file reads 并且引用的日志文件读取

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node',
1 verbose cli   '/usr/local/bin/npm',
1 verbose cli   'install',
1 verbose cli   'npm@latest' ]
2 info using npm@5.3.0
3 info using node@v8.5.0
4 verbose npm-session 5db7f116200ca64c
5 verbose stack Error: Cannot find module 'internal/errors'
5 verbose stack     at Function.Module._resolveFilename (module.js:527:15)
5 verbose stack     at Function.Module._load (module.js:476:23)
5 verbose stack     at Module.require (module.js:568:17)
5 verbose stack     at require (internal/module.js:11:18)
5 verbose stack     at evalmachine.<anonymous>:36:16
5 verbose stack     at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/cmd-shim/node_modules/graceful-fs/fs.js:11:1)
5 verbose stack     at Module._compile (module.js:624:30)
5 verbose stack     at Object.Module._extensions..js (module.js:635:10)
5 verbose stack     at Module.load (module.js:545:32)
5 verbose stack     at tryModuleLoad (module.js:508:12)
5 verbose stack     at Function.Module._load (module.js:500:3)
5 verbose stack     at Module.require (module.js:568:17)
5 verbose stack     at require (internal/module.js:11:18)
5 verbose stack     at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/cmd-shim/node_modules/graceful-fs/graceful-fs.js:3:27)
5 verbose stack     at Module._compile (module.js:624:30)
5 verbose stack     at Object.Module._extensions..js (module.js:635:10)
6 verbose cwd /Users/alexander/Documents/Source/Repos
7 verbose Darwin 16.7.0
8 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "npm@latest"
9 verbose node v8.5.0
10 verbose npm  v5.3.0
11 error code MODULE_NOT_FOUND
12 error Cannot find module 'internal/errors'
13 verbose exit [ 1, true ]

The same worked ok on the windows machine. 在Windows机器上运行正常。

What is the problem and how can I fix this? 有什么问题,如何解决这个问题?

Try to reinstall npm from the package in node v6.11.3LTS, and then 尝试从节点v6.11.3LTS中的软件包重新安装npm,然后

try to update to the latest npm v5.4.2 尝试更新到最新的npm v5.4.2

npm install npm@latest -g

and then update to the latest node v8.3.0 然后更新到最新的节点v8.3.0

npm install node@latest -g

I had the same issue, the above answer did not work. 我有同样的问题,上面的答案没有用。

I had old versions in node_modules. 我在node_modules中有旧版本。

I simply deleted everything in node_modules and then ran: 我只是删除了node_modules中的所有内容,然后运行:

npm install npm@latest -g

I had the same problem, and I solve it: 我有同样的问题,我解决了它:

  1. uninstall node and npm, do as this answer . 卸载节点和npm,做这个答案

  2. then install node 然后安装节点

     brew install node 

    and npm will also be installed. 和npm也将安装。

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

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