34

I ran this older 10.0.1 angular project today, and it told me it had a lot of low vulnerabilities and a few high ones. so i ran npm audit fix to fix them. but now when I try to run it, it gives me these errors:

Error: ./src/main.ts  
Module build failed (from ./node_modules/@ngtools/webpack/src/ivy/index.js):
TypeError: angularCompiler.getResourceDependencies(...) is not a function or its return value is not iterable
    at getDependencies (C:\Web\vgc\vgc\node_modules\@ngtools\webpack\src\ivy\plugin.js:261:56)
    at C:\Web\vgc\vgc\node_modules\@ngtools\webpack\src\ivy\plugin.js:374:20
    at analyzingFileEmitter (C:\Web\vgc\vgc\node_modules\@ngtools\webpack\src\ivy\plugin.js:307:20)
    at process._tickCallback (internal/process/next_tick.js:68:7)



Error: ./src/polyfills.ts  
Module build failed (from ./node_modules/@ngtools/webpack/src/ivy/index.js):
TypeError: angularCompiler.getResourceDependencies(...) is not a function or its return value is not iterable
    at getDependencies (C:\Web\vgc\vgc\node_modules\@ngtools\webpack\src\ivy\plugin.js:261:56)
    at C:\Web\vgc\vgc\node_modules\@ngtools\webpack\src\ivy\plugin.js:374:20
    at analyzingFileEmitter (C:\Web\vgc\vgc\node_modules\@ngtools\webpack\src\ivy\plugin.js:307:20)
    at process._tickCallback (internal/process/next_tick.js:68:7)

Any ideas how to fix this? I couldn't really find any relatable problems or solutions online.

4

12 回答 12

47

将 Angular CLI 从 10 升级到 11 对我有用。

ng update @angular/core @angular/cli
ng update
于 2021-01-27T20:43:03.623 回答
6

试试这个

rm -rf node_modules/
npm install
npm run build
于 2021-01-25T11:24:33.463 回答
2

我也解决了同样的问题。主要原因是“@angular-devkit/build-angular”版本在我的情况下不匹配。我改变了它的版本兼容的角度版本。就我而言,我使用的是 angular 10,之前版本以“0.11”开头,我将其更改为“0.1002.3”。

于 2021-04-06T08:54:38.660 回答
1

尝试这个:

rmdir /s node_modules
npm install "or" npm install @angular-devkit/build-angular
npm run build
于 2021-02-24T16:42:32.167 回答
1

我遇到了同样的问题。我为成功解决问题所做的工作:

  1. git restore package-lock.json
  2. git 恢复 package.json
  3. rm -rf 节点模块/
  4. npm 安装
  5. npm 开始

步骤的原因: 1.2。恢复原始包文件的步骤 3 步骤删除所有已安装的依赖项 4 步骤再次安装依赖项 毕竟,它恢复到原始状态,它可以工作。

于 2021-03-10T10:31:41.013 回答
0

我的客户让我们使用他们已经批准的某个版本。这对我来说是 v10。

在检查了适当的 package.json之后,我运行了以下命令来解决这个问题

npm i @angular-devkit/build-angular@0.1002.0 @angular-devkit/architect@0.1002.0 @angular-devkit/build-optimizer@0.1002.0 @angular-devkit/core@10.2.0 @angular-devkit/schematics@10.2.0 --save
于 2021-06-15T01:30:30.343 回答
0

除了以上所有,还得做一个额外的步骤:

  • 检查是否有重复版本的 webpack,但不知道它是如何引入的。树看着:

+-- @angular-devkit/build-angular@12.0.0 -- webpack@5.36.2 -- webpack@5.36.2

如果是这样,由( https://docs.npmjs.com/cli/v7/commands/npm-dedupe)修复:

npm 去重

于 2021-05-21T12:42:05.103 回答
0

你应该试试这个

ng update @angular/cli @angular/core --allow-dirty --force

我以前试过这个,但不允许在 Windows 操作系统中更新

ng update @angular/cli @angular/core

或者

ng update @angular/cli @angular/core --allow-dirty

这是由于 .\Temp\ng-fmB0C2\angular-errors.log 造成的问题

于 2021-05-12T05:00:05.253 回答
0

我的问题是由

"preserveSymlinks": true,

angular.json我的构建选项中缺少。

于 2021-11-11T11:56:43.093 回答
0

您可以通过将 Angular CLI 版本从 10 升级到 11 来解决此问题。作为#Craig 的回答。

否则,删除 node_modules、package-lock.json 文件。

恢复旧的 package.json 文件,然后运行 ​​npm install。或者不要做 npm 审计修复。

npm audit fix 升级/修改包依赖项,这是错误的。

于 2021-03-19T13:25:22.840 回答
-1

就我而言,我运行了 ng update @angular/cli@^11 @angular/core@^11

然后安装 webpack@4,因为其他包依赖它。

然后安装 tapable & @types/webpack 因为 webpack 4 插件需要它。

.. 并且几次删除 node_modules & npm install :)

于 2021-05-21T12:54:25.190 回答
-1

在我的情况下,安装以下软件包后问题就解决了。

npm install @ngtools/webpack

于 2021-04-11T07:41:06.540 回答