当我运行`ngnew`时,npm有一个依赖问题

我跑ng new在终端。我最终收到了 npm 错误

  1. 新建文件夹
  2. ng new在新文件夹中运行
  3. 设置名称并接受默认值(并使用 SCSS)
  4. 看着它在最后创建文件和错误
? Installing packages (npm)...npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: alexa-powell@0.0.0
npm ERR! Found: jasmine-core@3.7.1
npm ERR! node_modules/jasmine-core
npm ERR!   dev jasmine-core@"~3.7.0" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer jasmine-core@">=3.8" from karma-jasmine-html-reporter@1.7.0
npm ERR! node_modules/karma-jasmine-html-reporter
npm ERR!   dev karma-jasmine-html-reporter@"^1.5.0" 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/24wilber/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/24wilber/.npm/_logs/2021-07-11T18_12_50_796Z-debug.log
? Package install failed, see above.
The Schematic workflow failed. See above.

回答

我在一个新项目等中遇到了同样的问题。

在生成的内容中,package.json您应该看到一行内容,"jasmine-core": "~3.7.0"但似乎其他依赖项(我相信karma基于此处的错误输出)需要jasmine-core3.8.0 或更高版本。只需编辑说"jasmine-core": "~3.7.0",是的行,"jasmine-core": "~3.8.0",然后手动运行npm install,它应该会成功。

然后,您应该能够ng serve --open从同一目录运行并让它运行得很好。


以上是当我运行`ngnew`时,npm有一个依赖问题的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>