RTman
RTman

Reputation: 453

Errors after npm audit fix angular 10.0.1

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.

Upvotes: 35

Views: 62780

Answers (12)

Razze
Razze

Reputation: 4302

My problem was caused by

"preserveSymlinks": true,

missing from the angular.json in the options for my build.

Upvotes: 0

Croeber
Croeber

Reputation: 469

My clients make us be on a certain version, that they have approved. This is v10 for me.

I ran the below to solve this issue, after I inspected the appropriate package.json

npm i @angular-devkit/[email protected] @angular-devkit/[email protected] @angular-devkit/[email protected] @angular-devkit/[email protected] @angular-devkit/[email protected] --save

Upvotes: 1

mr.d1
mr.d1

Reputation: 1

For my case, I ran ng update @angular/cli@^11 @angular/core@^11

Then install webpack@4 since other package has dependencies on it.

Then install tapable & @types/webpack since webpack 4 plugin needs it.

.. and few times remove node_modules & npm install :)

Upvotes: -1

RMohamed
RMohamed

Reputation: 1

In addition to all of the above, have to do an extra step:

  • check if there is a duplicate versions of webpack, don't know how it was introduced though. The tree looked:

+-- @angular-devkit/[email protected] -- [email protected] -- [email protected]

If so, fixed by( https://docs.npmjs.com/cli/v7/commands/npm-dedupe ):

npm dedupe

Upvotes: 0

rajkanani
rajkanani

Reputation: 384

you should try this

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

I tried this before but that does not allow to update in windows os

ng update @angular/cli @angular/core

or

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

that's problem create beacuse of .\Temp\ng-fmB0C2\angular-errors.log

Upvotes: 0

Safyan Yaqoob
Safyan Yaqoob

Reputation: 552

In my case problem gone resolved after installing the below package.

npm install @ngtools/webpack

Upvotes: -1

msucil
msucil

Reputation: 846

I have also fixed the same issue. The main reason was the "@angular-devkit/build-angular" version which is not matching in my case. I changed it's version compatible angular version. In my case I am using angular 10 and previously the version started with "0.11" and I changed it to "0.1002.3".

Upvotes: 2

Vignesh PS
Vignesh PS

Reputation: 21

You can resolve this problem by Upgrading the Angular CLI version from 10 to 11. as #Craig answer.

or else, remove node_modules, package-lock.json file.

restore old package.json file and then run npm install. or don't do npm audit fix.

npm audit fix upgrades/modifies package dependencies, that's so made error.

Upvotes: 0

sunny
sunny

Reputation: 11

I faced the same problem. What I did to successfully fix the problem:

  1. git restore package-lock.json
  2. git restore package.json
  3. rm -rf node_modules/
  4. npm install
  5. npm start

The reasons of the steps: 1.2. steps to restore the origin package file 3 step to delete all the installed dependencies 4 step to install the dependencies again after all, it restores to the origin status, it works.

Upvotes: 1

user15276771
user15276771

Reputation: 11

Try this:

rmdir /s node_modules
npm install "or" npm install @angular-devkit/build-angular
npm run build

Upvotes: 1

Upgrading the Angular CLI from 10 to 11 works for me.

ng update @angular/core @angular/cli
ng update

Upvotes: 52

Darshan Malani
Darshan Malani

Reputation: 476

TRY this one

rm -rf node_modules/
npm install
npm run build

Upvotes: 6

Related Questions