angular: How to troubleshoot ngcc TypeError: Cannot read property 'fileName' of null

🐞 Bug report

when running ng build I get an exception during what I understand to be ngcc compiling @angular/core:

I am at a loss for how to troubleshoot this. This is a separate feature branch of a recently upgraded angular 12 project, incorporating changes from another developer. The base branch build correctly.

Command (mark with an x)

  • new
  • build
  • serve
  • test
  • e2e
  • generate
  • add
  • update
  • lint
  • extract-i18n
  • run
  • config
  • help
  • version
  • doc

Is this a regression?

No

Description

When running ng build, I see the following output: β ‹ Generating browser application bundles (phase: setup)… Compiling @angular/core : es2015 as esm2015

at which point I see the exception and the stack trace below. Note after an npm ci command, I also see the same message appear and complete successfully before it builds other node packages.

πŸ”¬ Minimal Reproduction

πŸ”₯ Exception or Error




An error occurred during the build:
TypeError: Cannot read property 'fileName' of null
    at Object.getImportRewriter (C:\Projects\xxxx\ngapp\node_modules\@angular\compiler-cli\ngcc\src\rendering\utils.js:23:72)
    at DtsRenderer.renderDtsFile (C:\Projects\xxxxx\ngapp\node_modules\@angular\compiler-cli\ngcc\src\rendering\dts_renderer.js:77:72)
    at C:\Projects\xxxx\ngapp\node_modules\@angular\compiler-cli\ngcc\src\rendering\dts_renderer.js:69:158
    at Map.forEach (<anonymous>)
    at DtsRenderer.renderProgram (C:\Projects\xxxx\ngapp\node_modules\@angular\compiler-cli\ngcc\src\rendering\dts_renderer.js:69:26)
    at Transformer.transform (C:\Projects\xxxx\ngapp\node_modules\@angular\compiler-cli\ngcc\src\packages\transformer.js:93:52)
    at C:\Projects\xxxx\ngapp\node_modules\@angular\compiler-cli\ngcc\src\execution\create_compile_function.js:52:42
    at SingleProcessExecutorSync.SingleProcessorExecutorBase.doExecute (C:\Projects\xxxx\ngapp\node_modules\@angular\compiler-cli\ngcc\src\execution\single_process_executor.js:36:17)
    at C:\Projects\xxxx\ngapp\node_modules\@angular\compiler-cli\ngcc\src\execution\single_process_executor.js:57:59
    at SyncLocker.lock (C:\Projects\xxxx\ngapp\node_modules\@angular\compiler-cli\ngcc\src\locking\sync_locker.js:34:24)
    at SingleProcessExecutorSync.execute (C:\Projects\xxxx\ngapp\node_modules\@angular\compiler-cli\ngcc\src\execution\single_process_executor.js:57:27)
    at Object.mainNgcc (C:\Projects\xxxx\ngapp\node_modules\@angular\compiler-cli\ngcc\src\main.js:74:25)
    at Object.process (C:\Projects\xxxx\ngapp\node_modules\@angular\compiler-cli\ngcc\index.js:29:23)
    at NgccProcessor.processModule (C:\Projects\xxxx\ngapp\node_modules\@ngtools\webpack\src\ngcc_processor.js:175:16)
    at C:\Projects\xxxx\ngapp\node_modules\@ngtools\webpack\src\ivy\host.js:146:18
    at C:\Projects\xxxx\ngapp\node_modules\@ngtools\webpack\src\ivy\host.js:76:24
An unhandled exception occurred: Cannot read property 'fileName' of null
See "C:\Users\xxxxxx\AppData\Local\Temp\ng-caDDPE\angular-errors.log" for further details.

🌍 Your Environment




Angular CLI: 12.1.3
Node: 14.17.0
Package Manager: npm 6.14.13
OS: win32 x64

Angular: 12.1.3
... animations, cli, common, compiler, co
... elements, forms, language-service, lo
... platform-browser, platform-browser-dy
... router

Package                         Version
-----------------------------------------
@angular-devkit/architect       0.1201.3
@angular-devkit/build-angular   12.1.3
@angular-devkit/core            12.1.3
@angular-devkit/schematics      12.1.3
@schematics/angular             12.1.3
rxjs                            6.6.7
typescript                      4.3.4
webpack                         5.41.1

Anything else relevant?

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 20 (10 by maintainers)

Most upvoted comments

yes. thank you for your time…