11

After running ng serve I've got an exception in terminal window:

Compiling @angular/core : module as esm5

Error: Error on worker #1: TypeError: Cannot read property 'map' of undefined

and message below:

An unhandled exception occurred: NGCC failed.

See /tmp/ng-EAdxWj/angular-errors.log for further details.

angular-errors.log:

[error] Error: NGCC failed.
    at NgccProcessor.process (/IdeaProjects/app/frontend/node_modules/@ngtools/webpack/src/ngcc_processor.js:76:19)
    at /IdeaProjects/app/frontend/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:579:31
    at SyncHook.eval [as call] (eval at create (/IdeaProjects/app/frontend/node_modules/tapable/lib/HookCodeFactory.js:19:10), <anonymous>:7:1)
    at SyncHook.lazyCompileHook (/IdeaProjects/app/frontend/node_modules/tapable/lib/Hook.js:154:20)
    at Object.webpack [as webpackFactory] (/IdeaProjects/app/frontend/node_modules/webpack/lib/webpack.js:55:30)
    at createWebpack (/IdeaProjects/app/frontend/node_modules/@angular-devkit/build-webpack/src/webpack-dev-server/index.js:20:36)
    at Object.runWebpackDevServer (/IdeaProjects/app/frontend/node_modules/@angular-devkit/build-webpack/src/webpack-dev-server/index.js:46:12)
    at SwitchMapSubscriber.project (/IdeaProjects/app/frontend/node_modules/@angular-devkit/build-angular/src/dev-server/index.js:191:32)
    at SwitchMapSubscriber._next (/IdeaProjects/app/frontend/node_modules/@angular-devkit/build-angular/node_modules/rxjs/internal/operators/switchMap.js:49:27)
    at SwitchMapSubscriber.Subscriber.next (/IdeaProjects/app/frontend/node_modules/@angular-devkit/build-angular/node_modules/rxjs/internal/Subscriber.js:66:18)
    at /IdeaProjects/app/frontend/node_modules/@angular-devkit/build-angular/node_modules/rxjs/internal/util/subscribeToPromise.js:7:24
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
Shlok Nangia
  • 2,355
  • 3
  • 16
  • 24
Serhii
  • 165
  • 1
  • 1
  • 8

4 Answers4

23

Just had the same Issue.

Fixed it by adding following to the tsconfig.app.json:

"angularCompilerOptions": {
    "enableIvy": false
},

Hope this helps

Felix
  • 262
  • 2
  • 3
  • 4
    Why does this work? The app works perfectly in a workmate's computer, but not in mine. This solved it, but it's not really the solution, as this fix is not ideal. – Javi Marzán Sep 15 '20 at 12:26
  • This error started for me after installing the flex-layout module, and remained even after I removed the faulty module. This workaround fixed the problem but, like you, I would like to understand what happened. – VictorEspina Sep 15 '20 at 16:49
  • 5
    @Felix, this means you disable the Ivy compiler and so use the old compiler (AOT). Are your sure, this is the right solution ? – Niko Oct 14 '20 at 14:32
  • 3
    I'm using Angular 11, there is only `tsconfig.json`, not `tsconfig.app.json`. And only `compilerOptions`, not `angularCompilerOptions`. Still added and got `enableIvy is not a valid option.` – Jeb50 Sep 09 '21 at 03:58
  • 1
    How disabling `ivy` is a solution? – Abdulrahman Hashem Jan 11 '22 at 08:54
  • 1
    @AbdulrahmanHashem It is not, and actually in 14 there is no such option anymore. – Victor Zakharov Oct 31 '22 at 12:12
6

I had the error:

Unknown arguments: use-program-dependencies, useProgramDependencies
An unhandled exception occurred: NGCC failed.
See "C:\...\angular-errors.log" for further details.

I just updated angular cli, material and core, and other modules needed to my project, then updated npm and typescript package, and that's all.

ng update @angular/cli @angular/core
npm update @angular/material @angular/cdk
npm install -g typescript@latest
Ruben Helsloot
  • 12,582
  • 6
  • 26
  • 49
Aldair Zepeda
  • 61
  • 1
  • 1
6

In my particular case the @angular-devkit/build-angular was updated to "^0.1002.0" in my package.json after running the npm audit fix. (This version seems to belong to angular 10, instead of the local projects' angular version (v9.1.3))

After reverting this change, everything started working again :

"@angular-devkit/build-angular": "~0.901.12"

Rahul Chandra
  • 483
  • 7
  • 15
  • ng update to v9 upgraded from v8 successfully, except for this package, which was `~0.1100.2` instead of 9. Set manually the version solved my issue – nelson6e65 Nov 20 '20 at 01:30
0

I have the same Linux setup locally and on a remote server. Locally it works, remotely I had "NGCC failed". Not very informative.

So I started to re-install everything: nodejs, npm, ng. I tried to purge and invalidate caches. Nothing helped.

Then at some point I got:

ENOMEM error thrown after spawn

Which brought me to Node.js catch ENOMEM error thrown after spawn

Indeed my hosting is 1Gb RAM and no swap. So I added it and magically ngcc started to work.

Now I wonder whether swap fixed it or my efforts to re-install everything on the remote server.