添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

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.

nom audit fix updates dependencies. Sometimes updated libraries are not compatible with other libraries or with your angular setup. Make sure you are using correct webpack version. – Kshitij Jan 22, 2021 at 17:28 Thanks for the answer, it indeed had to do something with compatibility problems. I updated the webpack library which fixed it but gave me some more pretty unexplickable errors. I tried fixing it for a bit but in the end I did the smart thing and saved myself the hassle by just copying everything over to a new clean project which works fine now. – RTman Jan 22, 2021 at 19:42 I'm facing the same problem. It started happening after installing tailwind on a fresh NX installation, I tried installing both 4 and 5 of webpack versions. no luck so far, any advice here? thanks. – Cristian Martinez Jan 25, 2021 at 19:26 I also noticed that webpack version didn't change after the installation of the package mentioned above, so it might be something else. webpack version: 4.43.0 – Cristian Martinez Jan 25, 2021 at 19:38

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

ng update @angular/core @angular/cli
ng update
                Updating to Angular 11 also solved the issue for me. Note that the command above will always update to the newest version
– user1839433
                Jan 28, 2021 at 9:29
                This did work for me, on reflection however, I should have tried tried Darshan's answer first of removing installed packages and doing a fresh package install. Fortunately, I do not have any other angular projects to be concerned about.
– Craig
                Feb 1, 2021 at 14:17
                It's not really an option when you have to keep the Angular version constant to maximise inter-project compatibility of components
– John White
                Feb 18, 2021 at 13:09
                You may also do npm start or any of your build script (instead of npm run build), which builds or serves your app.
– Random
                Jan 28, 2021 at 8:06
                "Try this" does not make for a good answer. You should explain how and why this solves their problem. I recommend reading, "How do I write a good answer?"
– John Conde
                Feb 24, 2021 at 20:35

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.

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/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

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.

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
ng update @angular/cli @angular/core --allow-dirty

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

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/build-angular@12.0.0 -- webpack@5.36.2 -- webpack@5.36.2

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

    npm dedupe

    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 :)

    Hello. Can we see your error logs? That would help shine light on the problem you are facing. – mondieki May 23, 2021 at 16:27

    Thanks for contributing an answer to Stack Overflow!

    • Please be sure to answer the question. Provide details and share your research!

    But avoid

    • Asking for help, clarification, or responding to other answers.
    • Making statements based on opinion; back them up with references or personal experience.

    To learn more, see our tips on writing great answers.