npm 审核修复 --force 导致错误:数据路径“.builders['app-shell']”应具有必需的属性“class”

mat*_*att 5 npm angular-cli angular

安装软件包后我收到此消息:

added 1 package from 8 contributors and audited 49729 packages in 23.754s
found 25 vulnerabilities (1 low, 24 high)
  run `npm audit fix` to fix them, or `npm audit` for details
Run Code Online (Sandbox Code Playgroud)

所以我运行npm audit fix并修复了一些漏洞。

...
+ @angular-devkit/build-ng-packagr@0.800.2
+ @angular-devkit/build-angular@0.800.2
added 125 packages from 72 contributors, updated 8 packages and moved 16 packages in 65.005s
fixed 12 of 25 vulnerabilities in 49729 scanned packages
  3 package updates for 13 vulns involved breaking changes
  (use `npm audit fix --force` to install breaking changes; or refer to `npm audit` for steps to fix these manually)
Run Code Online (Sandbox Code Playgroud)

它建议使用 npmauditfix --force,我使用了它,现在当我尝试运行 Angular 应用程序时,它收到此错误:

Schema validation failed with the following errors:
  Data path ".builders['app-shell']" should have required property 'class'.
Error: Schema validation failed with the following errors:
Run Code Online (Sandbox Code Playgroud)

发生了什么事,我应该使用 npm 审核修复还是忽略警告。如何让我的应用程序再次运行?

在我运行强制修复后它显示此消息,但已经运行命令为时已晚:

npm WARN using --force I sure hope you know what you are doing.
Run Code Online (Sandbox Code Playgroud)

安装的软件包:

https://stackblitz.com/edit/typescript-uuubb8

Mar*_*ndt 4

始终要小心旗帜--force。这就像通过拔掉电缆来关闭计算机一样。你基本上“强迫”NPM 做你想让它做的事情,即使 NPM 知道你的应用程序会崩溃。

要解决此问题,您必须手动恢复更​​改。

你也可以尝试运行npm update。它将更新每个包(但之前备份您的项目!)。也许这足以解决它。

如果您将来必须修复漏洞,请在不使用该--force标志的情况下进行修复。如果这不起作用,请通过运行手动执行npm audit:它将向您显示问题的详细信息,而不需要执行任何操作。