我在终端中运行了ng new
。我最终得到了一个npm错误
- 新文件夹
- 在新文件夹中运行
ng new
- 设置名称并接受默认值(并使用SCSS(
- 看着它创建文件并在最后出错
⠸ Installing packages (npm)...npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: project-name@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/user/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/user/.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
基于此处的错误输出(需要3.8.0或更高版本的jasmine-core
。只需将"jasmine-core": "~3.7.0",
的行编辑为"jasmine-core": "~3.8.0",
,然后手动运行npm install
,它就会成功。
然后,您应该能够从同一目录运行ng serve --open
,并使其正常运行。
我更改了"茉莉花心":"3.7.0";,至";茉莉花心":"3.8.0";在package.json.template中,我现在可以创建没有问题的项目。地点可能有所不同,我的是:/usr/local/lib/node_modules/@angular/cli/nod_module/@schemicals/angular/workspace/files/package.json.template
这将解决新项目中的问题