【问题标题】:Cannot execute npm commands无法执行 npm 命令
【发布时间】:2019-02-25 01:45:32
【问题描述】:

在尝试安装 gulp 包时,我收到此错误消息。

module.js:471
throw err;
^

Error: Cannot find module './auth.js'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> 
(/usr/local/lib/node_modules/npm/node_modules/npm-registry- 
fetch/index.js:7:17)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)

进一步尝试后,我意识到我无法执行任何其他 npm 命令。它总是显示此消息。我该如何解决这个问题?

我什至尝试过这样做,

sudo rm -rf node_modules
npm install

但我总是再次收到这条消息。

谢谢。

【问题讨论】:

  • 你最近升级 NPM 了吗?

标签: npm terminal


【解决方案1】:

这对我有帮助

sudo n stable

答案来源:How can I update NodeJS and NPM to the next versions?

【讨论】:

  • 这很有帮助,因为 'n' 是一个 Node 版本切换器,这意味着它会将您切换到新版本的 Node(其中包括不同版本的 NPM)。所以它与其他答案相同,但非常方便。
【解决方案2】:

您的 npm 安装可能已损坏。将 npm 更新到 6.8.0 后我遇到了同样的问题 通常,您会使用 npm 为 npm 安装不同的版本,但由于这不起作用,您可以下载 NodeJs 安装程序(从 nodejs.org)并重新安装 NodeJs。它(当前)附带对我有用的 npm 6.4。

【讨论】:

    猜你喜欢
    • 2016-06-03
    • 2019-11-28
    • 2017-01-11
    • 1970-01-01
    • 2021-10-19
    • 2017-09-14
    • 1970-01-01
    • 1970-01-01
    • 2020-06-19
    相关资源
    最近更新 更多