简体   繁体   English

NPM:找不到模块“../lib/utils/unsupported.js”

[英]NPM: Cannot find module '../lib/utils/unsupported.js'

I'm getting the following error when trying to do anything with npm:尝试对 npm 执行任何操作时出现以下错误:

internal/modules/cjs/loader.js:638
    throw err;
    ^

Error: Cannot find module '../lib/utils/unsupported.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:690:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at /usr/local/lib/node_modules/npm/bin/npm-cli.js:19:21
    at Object.<anonymous> (/usr/local/lib/node_modules/npm/bin/npm-cli.js:153:3)
    at Module._compile (internal/modules/cjs/loader.js:776:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)

I can't run npx create-react-app or any npm commands including uninstalling or updating npm.我无法运行 npx npx create-react-app或任何npm命令,包括卸载或更新 npm。 Yesterday I installed yarn , could that be part of the problem?昨天我安装了yarn ,这可能是问题的一部分吗? I also updated my Mac to Catalina 10.15.5 recently.我最近也将我的 Mac 更新到了Catalina 10.15.5 I'm not sure if either/both of these caused the npm issue or not.我不确定这两者是否导致 npm 问题。

What's causing this and how can I fix it?是什么原因造成的,我该如何解决?

Found a solution.找到了解决方案。 A modified version of this answer worked. 此答案的修改版本有效。

I ran:我跑了:

brew uninstall --force node

sudo rm -r /usr/local/lib/node_modules

brew install node

and that did the trick.这就是诀窍。

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

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