运行 ng 新命令时茉莉花版本错误

jasmine version error while running ng new command

我在 运行 ng 新命令时遇到错误 在 ng new Project-Name-Here

期间会触发以下错误

无法解决依赖关系: 来自 karma-jasmine-html-reporter@1.6.0

的错误 peer jasmine-core@">=3.7.1"
silly fetch manifest jasmine-core@>=3.7.1
83 timing idealTree Completed in 8839ms
84 timing command:install Completed in 8849ms
85 verbose stack Error: unable to resolve dependency tree
85 verbose stack     at Arborist.[failPeerConflict] (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:1141:25)
85 verbose stack     at Arborist.[loadPeerSet] (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:1118:34)
85 verbose stack     at async Arborist.[buildDepStep] (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:836:11)
85 verbose stack     at async Arborist.buildIdealTree (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:209:7)
85 verbose stack     at async Promise.all (index 1)
85 verbose stack     at async Arborist.reify (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\reify.js:130:5)
85 verbose stack     at async install (C:\Program Files\nodejs\node_modules\npm\lib\install.js:38:3)
86 verbose cwd C:\Users\PYH0JFQ\source\Hospital\Patient
87 verbose Windows_NT 10.0.19041
88 verbose argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "install" "--quiet"
89 verbose node v15.11.0
90 verbose npm  v7.6.0
91 error code ERESOLVE
92 error ERESOLVE unable to resolve dependency tree
93 error
94 error While resolving: patient@0.0.0
94 error Found: jasmine-core@3.6.0
94 error node_modules/jasmine-core
94 error   dev jasmine-core@"~3.6.0" from the root project
94 error
94 error Could not resolve dependency:
94 error peer jasmine-core@">=3.7.1" from karma-jasmine-html-reporter@1.6.0
94 error node_modules/karma-jasmine-html-reporter
94 error   dev karma-jasmine-html-reporter@"^1.5.0" from the root project
94 error
94 error Fix the upstream dependency conflict, or retry
94 error this command with --force, or --legacy-peer-deps
94 error to accept an incorrect (and potentially broken) dependency resolution.

我最近遇到了同样的问题,我是从在线讲师那里了解到的。 无论如何,你应该把问题措辞清楚

此错误是由 npm 7 问题引起的。 Angular 团队建议暂时使用 npm 6。 所以现在将 npm 7 降级为 npm 6

npm install -g npm@6

另一种方法是 运行 使用 --skipInstall 标志 ng new,然后使用 npm install --legacy-peer-deps 安装依赖项。

我发现了一个更好的解决方案。 在 运行 宁 ng new 之后 - 进入 package.json 并简单地更改

"jasmine-core": "~3.7.0",

"jasmine-core": "~3.8.0",

然后 运行 npm install 之后。