Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Builder @angular/build:application for v19 throws a runtime error "The injectable '_PlatformNavigation' needs to be compiled using the JIT compiler, but '@angular/compiler' is not available." #29624

Open
surenrao opened this issue Feb 10, 2025 · 4 comments
Labels
needs: repro steps We cannot reproduce the issue with the information given

Comments

@surenrao
Copy link

surenrao commented Feb 10, 2025

Which @angular/* package(s) are the source of the bug?

Don't known / other

Is this a regression?

Yes

Description

We just updated our app from Angular 17 to Angular 19 (using cli ng update). After fixing some minor warnings, errors and updating to new builder "@angular/build:application", we are getting below error in chrome devtool console. (although initial testing shows that the app is working without any issue)

JIT compilation failed for injectable class _PlatformNavigation

Uncaught Error: The injectable '_PlatformNavigation' needs to be compiled using the JIT compiler, but '@angular/compiler' is not available.

Adding import "@angular/compiler in main.ts before bootstrapping did not fix it.
How can we fix the warning?

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

`
JIT compilation failed for injectable class _PlatformNavigation {
  static \u0275fac = \u0275\u0275ngDeclareFactory({ minVersion: "12.0.0", version: "19.1.4", ngImport: core_exports, type: _PlatformNavigation, deps: [], target: FactoryTarget.Injectable });
  static \u0275prov = \u0275\u0275ngDeclareInjectable({ minVersion: "12.0.0", version: "19.1.4", ngImport: core_exports, type: _PlatformNavigation, providedIn: "platform", useFactory: () => window.navigation });
}
`

`
Uncaught Error: The injectable '_PlatformNavigation' needs to be compiled using the JIT compiler, but '@angular/compiler' is not available.

The injectable is part of a library that has been partially compiled.
However, the Angular Linker has not processed the library such that JIT compilation is used as fallback.

Ideally, the library is processed using the Angular Linker to become fully AOT compiled.
Alternatively, the JIT compiler should be loaded by bootstrapping using '@angular/platform-browser-dynamic' or '@angular/platform-server',
or manually provide the compiler with 'import "@angular/compiler";' before bootstrapping.
    at getCompilerFacade (compiler_facade.ts:45:11)
    at ɵɵngDeclareFactory (partial.ts:107:20)
    at <static_initializer> (platform_navigation.ts:29:41)
    at platform_navigation.ts:29:23
`

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 19.1.5
Node: 22.13.1
Package Manager: yarn 1.22.22
OS: win32 x64

Angular: 19.1.4
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.1901.6
@angular-devkit/core         19.1.6
@angular-devkit/schematics   19.1.5
@angular/build               19.1.6
@angular/cli                 19.1.5
@schematics/angular          19.1.5
rxjs                         7.8.1
typescript                   5.5.4
zone.js                      0.15.0

Anything else?

No response

@JoostK
Copy link
Member

JoostK commented Feb 10, 2025

Please share a reproduction as without one this won't be actionable.

@atscott
Copy link
Contributor

atscott commented Feb 12, 2025

@alan-agius4 This looks like #28523

@alan-agius4 alan-agius4 transferred this issue from angular/angular Feb 12, 2025
@alan-agius4 alan-agius4 added the needs: repro steps We cannot reproduce the issue with the information given label Feb 12, 2025
@alan-agius4
Copy link
Collaborator

Can you setup a minimal repro please?

You can read here why this is needed. A good way to make a minimal repro is to create a new app via ng new repro-app and adding the minimum possible code to show the problem. Then you can push this repository to github and link it here.

This might be related to your directory structure so its really important to get an accurate repro to diagnose this.

@surenrao
Copy link
Author

So while creating a minimum repro, we found that a our team's external angular library is causing this. i am still in process of extracting code but looks like will take some time.
Also please note this is the first time we are moving to the new build system (we were using @angular-builders/custom-webpack before. Which doesnt give the runtime error in browser console but shows sass deprecation warning in cli)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs: repro steps We cannot reproduce the issue with the information given
Projects
None yet
Development

No branches or pull requests

4 participants