【问题标题】:error running npm install on mac bigsur M1在 mac bigsur M1 上运行 npm install 时出错
【发布时间】:2021-10-31 18:35:51
【问题描述】:

当我在我的项目上运行 npm install 时,我得到了

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: .....@10.1.3
npm ERR! Found: @angular/forms@11.2.14
npm ERR! node_modules/@angular/forms
npm ERR!   @angular/forms@"^11.2.14" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/forms@"^12.0.0" from ngx-typesafe-forms@1.5.1
npm ERR! node_modules/ngx-typesafe-forms
npm ERR!   ngx-typesafe-forms@"^1.4.3" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 
npm ERR! See /Users/..../.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/.../.npm/_logs/2021-09-02T10_06_13_858Z-debug.log

然后我尝试了我尝试运行 npm install --legacy-peer-deps 并得到了

npm ERR! 1 error generated.
npm ERR! make: *** [Release/obj.target/binding/src/binding.o] Error 1
npm ERR! gyp ERR! build error 
npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
npm ERR! gyp ERR! stack     at ChildProcess.onExit (/Users/......./node_modules/node-gyp/lib/build.js:262:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:394:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
npm ERR! gyp ERR! System Darwin 20.6.0
npm ERR! gyp ERR! command "/opt/homebrew/Cellar/node/16.4.2/bin/node" "/Users/...../node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
npm ERR! gyp ERR! cwd /Users/......../node_modules/node-sass
npm ERR! gyp ERR! node -v v16.4.2
npm ERR! gyp ERR! node-gyp -v v3.8.0
npm ERR! gyp ERR! not ok 
npm ERR! Build failed with error code: 1

我已尝试删除我的 node_modules 文件夹并再次运行它。

npm -v = 7.21.1

【问题讨论】:

  • 你试过npm cache clean --force吗?
  • 是的,我有:(不幸的是我仍然遇到同样的问题
  • 类似于在node-gyp repo 中打开Issue #2458
  • 我找到了this。您可以尝试几种解决方法(使用 nvm 安装节点,取消 package.json 并重新运行 npm install...)。如果你解决了,请告诉我。

标签: node.js macos npm apple-m1


【解决方案1】:

我遇到了同样的问题,我的 Angular 项目版本是 9,node 版本是 16,npm 版本是 8。 只需降级您的节点版本,然后运行 ​​npm install 它对我有用。 使用与第一次创建 package-lock.json 文件相同的节点版本。 希望这有帮助

【讨论】:

  • 谢谢。就我而言,降级到节点版本 14 解决了这个问题。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-10-02
  • 2019-03-11
  • 2018-11-22
  • 2017-04-12
  • 1970-01-01
  • 2016-02-09
相关资源
最近更新 更多