question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

🐞 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?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:20 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
scomocommented, Jul 26, 2021

yes. thank you for your time…

0reactions
angular-automatic-lock-bot[bot]commented, Aug 26, 2021

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ERROR in Cannot read property 'fileName' of null After ...
Today I upgraded angular 8 to 9 and I got same error: TypeError: Cannot read property 'fileName' of null . After reseaches I...
Read more >
Error In Cannot Read Property 'Filename' Of Null After ...
It results in an error saying Cannot read property 'fileName' of null. This is not a problem with our repo as this even...
Read more >
Yes its great one ever. now I facing a […] - Discussion on Appwork
Compiling @angular/compiler/testing : module as esm5. Error: Error on worker #3: TypeError: Cannot read property 'fileName' of null at Object.
Read more >
Angular 9 – NGCC fails with an unhandled exception
Angular 9 – NGCC fails with an unhandled exception ... Error: Error on worker #5: TypeError: Cannot read property 'fileName' of null.
Read more >
Angular
Error: Failed to initialize Angular compilation - Cannot read properties of null (reading 'fileName'). ** Angular Live Development Server is ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found