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.

TypeError: Cannot read property 'text' of undefined - Error: NGCC failed.

See original GitHub issue

🐞 Bug report

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?

Yes, the previous version in which this bug was not present was: 12.2.10

Description

After upgrading angular from version 12.2.10 to 12.2.11 or 12.2.12, I can't build anymore my project.

πŸ”¬ Minimal Reproduction

I attached a repo-app, under the project folder, run the follwoing to reproduce the error:


npm i
ng build

πŸ”₯ Exception or Error




- Generating browser application bundles (phase: setup)...TypeError: Cannot read property 'text' of undefined
    at NodeObject.getText (C:\Users\user\git\angular\repro-app\node_modules\typescript\lib\typescript.js:148615:31)
    at getRequiredModulePath (C:\Users\user\git\angular\repro-app\node_modules\@angular\compiler-cli\ngcc\src\host\umd_host.js:519:99)
    at Object.getImportsOfUmdModule (C:\Users\user\git\angular\repro-app\node_modules\@angular\compiler-cli\ngcc\src\host\umd_host.js:510:23)
    at UmdDependencyHost.extractImports (C:\Users\user\git\angular\repro-app\node_modules\@angular\compiler-cli\ngcc\src\dependencies\umd_dependency_host.js:43:54)
    at UmdDependencyHost.DependencyHostBase.recursivelyCollectDependencies (C:\Users\user\git\angular\repro-app\node_modules\@angular\compiler-cli\ngcc\src\dependencies\dependency_host.js:85:32)
    at UmdDependencyHost.DependencyHostBase.collectDependencies (C:\Users\user\git\angular\repro-app\node_modules\@angular\compiler-cli\ngcc\src\dependencies\dependency_host.js:38:22)
    at DependencyResolver.getEntryPointWithDependencies (C:\Users\user\git\angular\repro-app\node_modules\@angular\compiler-cli\ngcc\src\dependencies\dependency_resolver.js:75:22)
    at EntryPointCollector.walkDirectoryForPackages (C:\Users\user\git\angular\repro-app\node_modules\@angular\compiler-cli\ngcc\src\entry_point_finder\entry_point_collector.js:47:52)
    at EntryPointCollector.walkDirectoryForPackages (C:\Users\user\git\angular\repro-app\node_modules\@angular\compiler-cli\ngcc\src\entry_point_finder\entry_point_collector.js:75:103)
    at C:\Users\user\git\angular\repro-app\node_modules\@angular\compiler-cli\ngcc\src\entry_point_finder\program_based_entry_point_finder.js:124:100
C:\Users\user\git\angular\repro-app\node_modules\@ngtools\webpack\src\ngcc_processor.js:139
            throw new Error(errorMessage + `NGCC failed${errorMessage ? ', see above' : ''}.`);
            ^

Error: NGCC failed.
    at NgccProcessor.process (C:\Users\user\git\angular\repro-app\node_modules\@ngtools\webpack\src\ngcc_processor.js:139:19)
    at C:\Users\user\git\angular\repro-app\node_modules\@ngtools\webpack\src\ivy\plugin.js:129:27
    at Hook.eval [as call] (eval at create (C:\Users\user\git\angular\repro-app\node_modules\tapable\lib\HookCodeFactory.js:19:10), <anonymous>:20:1)
    at Hook.CALL_DELEGATE [as _call] (C:\Users\user\git\angular\repro-app\node_modules\tapable\lib\Hook.js:14:14)
    at Compiler.newCompilation (C:\Users\user\git\angular\repro-app\node_modules\webpack\lib\Compiler.js:1043:30)
    at C:\Users\user\git\angular\repro-app\node_modules\webpack\lib\Compiler.js:1088:29
    at Hook.eval [as callAsync] (eval at create (C:\Users\user\git\angular\repro-app\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:22:1)
    at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (C:\Users\user\git\angular\repro-app\node_modules\tapable\lib\Hook.js:18:14)
    at Compiler.compile (C:\Users\user\git\angular\repro-app\node_modules\webpack\lib\Compiler.js:1083:28)
    at C:\Users\user\git\angular\repro-app\node_modules\webpack\lib\Watching.js:200:19

🌍 Your Environment




Angular CLI: 12.2.12
Node: 14.18.1
Package Manager: npm 6.14.15
OS: win32 x64

Angular: 12.2.12
... animations, cdk, cli, common, compiler, compiler-cli, core
... forms, google-maps, language-service, localize, material
... platform-browser, platform-browser-dynamic, platform-server
... router, service-worker

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.1200.5
@angular-devkit/build-angular     12.2.12
@angular-devkit/build-optimizer   0.1200.5
@angular-devkit/core              12.0.5
@angular-devkit/schematics        12.2.12
@nguniversal/builders             12.1.3
@nguniversal/express-engine       12.1.3
@schematics/angular               12.2.12
ng-packagr                        12.2.5
rxjs                              6.6.7
typescript                        4.2.4

Anything else relevant?

Kindly check below a zip of an angular-cli project to reproduce the error: repro-app.zip

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:5
  • Comments:19 (7 by maintainers)

github_iconTop GitHub Comments

5reactions
gkalpakcommented, Nov 30, 2021

This fix has been merged and will be included in the next v13 release (13.0.3).

@PraveenFrancis, typically we wouldn’t backport this to v12 (which is an LTS version) based on our release policy, but since it was an easy/clean backport and we are releasing an LTS version to fix some other issues/regressions, I created #44309. So, the fix will eventually land to the v12 branch, but not sure when the next v12 release will be (could be in a month or so).

1reaction
4kparadisecommented, Dec 2, 2021

You’re right, forget to update the compiler-cli to 13.0.3 too. My fault, now it works!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot read property 'text' of undefined at NodeObject.getText ...
An error occurred during the build: Error: NGCC failed. at NgccProcessor.process (/opt/app-root/src/node_modules/@ngtools/webpack/src/Β ...
Read more >
error: failed to initialize angular compilation - ngcc failed.
After upgrading to Angular 12 getting Error: NGCC failed ... TypeError: Cannot read property 'text' of undefined at NodeObject.
Read more >
Angular 8 Webpack Aot Build Failed - Cannot Read Property ...
6 and we got the error: Uncaught TypeError: Cannot read property 'type' of Angular Ngrx 8 Selector error: Cannot read property 'map' of...
Read more >
error AggregateException The NPM script 'start' exited without ...
this error happens due to json files wrong encoding so you must ensure that all your json files like (angular-cli.json, tslint.json and tsconfigΒ ......
Read more >
why is the error NGCC failed during ng serve Code Example
rm -rf node_modules // this will delete all your modules npm install //this will reinstall the need modules on your project.
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