javascript - 为什么 ng new newApp 生成无法解决依赖树错误

标签 javascript node.js angular web npm

我正在尝试使用命令创建一个新的 Angular 应用程序 ng new app-name ..但是运行命令后,它在命令行中显示以下内容。

Installing packages (npm)...npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: angular-module@0.0.0
npm ERR! Found: jasmine-core@3.6.0
npm ERR! node_modules/jasmine-core
npm ERR!   dev jasmine-core@"~3.6.0" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer jasmine-core@">=3.7.1" from karma-jasmine-html-reporter@1.6.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 /home/vazha/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/vazha/.npm/_logs/2021-05-07T05_12_55_121Z-debug.log
✖ Package install failed, see above.
The Schematic workflow failed. See above.
我们如何解决这个问题?

最佳答案

此错误是由 npm 7 问题引起的。 Angular 团队建议现在使用 npm 6。
运行npm install -g npm@6以确保您使用的是该版本。
另一种方法是运行 ng new--skipInstall标记,然后使用 npm install --legacy-peer-deps 安装依赖项.

关于javascript - 为什么 ng new newApp 生成无法解决依赖树错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62910471/

相关文章:

javascript - 如何使用 onbeforeunload 作为后退按钮但防止表单提交和内部页面重定向

javascript - 全局监控未兑现的 promise 以显示指标

javascript - Node.js 表示 post 参数始终未定义

node.js - 在 React 上使用 Youtube v3 API 的 maxResults

javascript - 禁用 div 并仅在选择单选按钮选项时启用

angular - 错误类 'FirebaseApp' 错误地实现了接口(interface) 'App'

javascript - HTML 和 Web API 之间的不同输入数据

javascript - 单击时如何将 td-tag 更改为 html 中的 input-tag?

android - 如何在 WhatsApp Business 应用程序中打开 wa.me 链接,而不是在同一部手机上打开个人 WhatsApp?

javascript - 在 Node.js 中从 Web 运行一个库