We recently upgraded our Angular application from Angular 17 to Angular 20, and we are encountering a runtime dependency injection error related to ABP Angular packages.
The error occurs during application startup and seems to be related to RestService from abp-ng.core.
Error Details RuntimeError: NG0201 at R3Injector.get (root_effect_scheduler.mjs:2081:27) at R3Injector.get (root_effect_scheduler.mjs:2052:33) at R3Injector.retrieve (root_effect_scheduler.mjs:1936:25) at injectInjectorOnly (root_effect_scheduler.mjs:1049:39) at ɵɵinject (root_effect_scheduler.mjs:1061:42) at inject2 (root_effect_scheduler.mjs:1149:12) at new _RestService (abp-ng.core.mjs:2213:20)
Current Setup Angular Version: 20 Using custom AbpModule to group all ABP-related modules Using NgModule-based architecture (not standalone)
AppModule Configuration
@NgModule({
imports: [
AbpModule,
BrowserModule,
BrowserAnimationsModule,
AppRoutingModule,
HttpClientModule,
// other modules...
],
providers: [
....,
{
provide: AuthService,
useClass: NxPAuthServiceService,
}
],
})
export class AppModule {}
@NgModule({
imports: [
CoreModule.forRoot({ environment, registerLocaleFn: registerLocale(), }),
AbpOAuthModule.forRoot(),
ThemeSharedModule.forRoot(),
// multiple ABP config modules...
],
exports: [
CoreModule,
AbpOAuthModule,
ThemeSharedModule, // same modules exported...
]
})
export class AbpModule {}
Actual Behavior Application fails at startup with NG0201 (No provider found) related to RestService.
Is there a recommended way to structure AbpModule in newer Angular versions? Do we need to migrate to standalone APIs (bootstrapApplication) for compatibility?
Any guidance or recommended migration steps would be greatly appreciated.
Thanks Imrankhan
5 Answer(s)
-
0
- You do not need to migrate to standalone (
bootstrapApplication) just to fix this. ABP Angular packages still work with NgModule-based apps. RestServiceis already provided in root, soNG0201: No provider found for RestServicetypically indicates the@abp/*packages are not being resolved/loaded correctly, or ABP’s core options/providers are not actually being registered due to build/package resolution issues.
1) Ensure ABP Core is initialized exactly once (root module only)
Keep
CoreModule.forRoot(...)only in a module that is imported byAppModule(directly or through yourAbpModule) and make sure it is not imported again elsewhere.Your
AbpModuleapproach is OK, but make sure other feature/shared modules don’t importCoreModuleagain (they should importCoreModulewithoutforRoot, or not import it at all if not needed).2) Fix common Angular 20 + ABP DI “no provider” cause: TS
pathsoverriding@abp/*After upgrades, a very common reason for ABP DI tokens/providers not being found is that your
tsconfig*.jsoncontainspathsmappings that cause@abp/*(and/or@volo/*) to resolve to something other thannode_modules(e.g., a localprojects/*folder, old source copies, monorepo mappings, etc.).Add (or override) these mappings in the tsconfig used by the Angular app that runs (often
tsconfig.app.jsonorapps/<app>/tsconfig.json):{ "compilerOptions": { "paths": { "@abp/*": ["node_modules/@abp/*"], "@volo/*": ["node_modules/@volo/*"] } } }Then clean + reinstall:
rm -rf node_modules package-lock.json yarn.lock npm install # or yarn npm startThis ensures Angular resolves
@abp/ng.corefrom the installed package (whereRestServiceis registered), not from an unintended location.3) Keep package versions normalized (important after major Angular upgrade)
Make sure all
@abp/*and@volo/*packages are on the same ABP minor/patch line (don’t mix different 10.x.y versions). Mixed versions can cause DI/provider graph mismatches at runtime.
If you apply (2) + clean install, this usually resolves “No provider found for RestService” symptoms in Angular 20 upgrades.
Links:
- https://abp.io/docs/latest/framework/ui/angular/http-requests
- https://abp.io/support/questions/10506
This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon.
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) - You do not need to migrate to standalone (
-
0
Hi,
Thanks for the detailed report. Before suggesting a fix, could you share the output of:
npm list @abp/ng.coreThe reason is: the error "No provider found for RestService" is unusual — in newer ABP versions
RestServiceisprovidedIn: 'root'and should always be resolvable. If you're on an older ABP version (built for Angular 17), the compiled package may not be compatible with Angular 20's DI runtime, which would explain why the provider registration silently fails.In the meantime, there's one thing in your
AppModulethat should be fixed regardless:@NgModule({ imports: [ AbpModule, BrowserModule, BrowserAnimationsModule, AppRoutingModule, // HttpClientModule, ← remove this ], }) export class AppModule {}HttpClientModule(old API) should be removed. ABP'sCoreModule.forRoot()already sets upHttpClientinternally viaprovideHttpClient(). Having both at the same time can cause provider conflicts in Angular 20.However, if the error persists after removing
HttpClientModule, the most likely root cause is that your@abp/ng.*packages were compiled for Angular 17 and are not compatible with Angular 20. In that case, upgrading all@abp/ng.*packages to a version that officially supports Angular 20 would be the required fix.To answer your questions directly:
- No, you don't need to migrate to standalone APIs — NgModule-based architecture is still fully supported.
- No, the
AbpModulewrapper pattern is not the problem.
Please share your ABP package version and we can give you more targeted guidance.
Thanks
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
npm list @abp/ng.core result
nxp@0.0.32 E:\projects\NxP-Design\NxP\apps\design-system +-- @abp/ng.account@10.2.0 | `-- @abp/ng.account.core@10.2.0 | `-- @abp/ng.core@10.2.0 deduped +-- @abp/ng.components@10.2.0 | `-- @abp/ng.core@10.2.0 deduped +-- @abp/ng.core@10.2.0 +-- @abp/ng.oauth@10.2.0 | `-- @abp/ng.core@10.2.0 deduped +-- @abp/ng.theme.shared@10.2.0 | `-- @abp/ng.core@10.2.0 deduped `-- @volo/abp.ng.account.core@10.2.0 `-- @abp/ng.core@10.2.0 dedupedPackages
"@abp/ng.account": "10.2.0", "@abp/ng.components": "10.2.0", "@abp/ng.core": "10.2.0", "@abp/ng.oauth": "10.2.0", "@abp/ng.setting-management": "10.2.0", "@abp/ng.theme.shared": "10.2.0", "@angular/animations": "21.0.0", "@angular/common": "21.0.0", "@angular/compiler": "21.0.0", "@angular/core": "21.0.0", "@angular/aria": "~21.1.0", "@angular/forms": "21.0.0", "@angular/localize": "21.0.0", "@angular/platform-browser": "21.0.0", "@angular/platform-browser-dynamic": "21.0.0", "@angular/router": "21.0.0", "@volo/abp.commercial.ng.ui": "10.2.0", "@volo/abp.ng.account.core": "10.2.0", "@volo/abp.ng.audit-logging": "10.2.0", "@volo/abp.ng.chat": "10.2.0", "@volo/abp.ng.gdpr": "10.2.0", "@volo/abp.ng.identity": "10.2.0", "@volo/abp.ng.language-management": "10.2.0", "@volo/abp.ng.openiddictpro": "10.2.0", "@volo/abp.ng.saas": "10.2.0", "@volo/abp.ng.text-template-management": "10.2.0", "@volosoft/abp.ng.theme.lepton-x": "~5.2.0",I changed the app module as below.
imports: [ BrowserModule, BrowserAnimationsModule, CoreModule.forRoot({ environment, registerLocaleFn: registerLocale(), }), AbpOAuthModule.forRoot(), ThemeSharedModule.forRoot({ httpErrorConfig: { errorScreen: { component: HttpErrorComponent, forWhichErrors: [401, 403, 404, 500], hideCloseIcon: true, }, }, }), AccountAdminConfigModule.forRoot(), AccountPublicConfigModule.forRoot(), AccountConfigModule.forRoot(), IdentityConfigModule.forRoot(), LanguageManagementConfigModule.forRoot(), SaasConfigModule.forRoot(), AuditLoggingConfigModule.forRoot(), OpeniddictproConfigModule.forRoot(), TextTemplateManagementConfigModule.forRoot(), SettingManagementConfigModule.forRoot(), FeatureManagementModule.forRoot(), ThemeLeptonXModule.forRoot(), SideMenuLayoutModule.forRoot(), CommercialUiConfigModule.forRoot(), ChatConfigModule.forRoot(), .... other modulesAfter this changes, I am getting following error now.
ERROR RuntimeError: NG0201 at R3Injector.get (_untracked-chunk.mjs:1204:17) at R3Injector.get (_untracked-chunk.mjs:1192:27) at R3Injector.retrieve (_untracked-chunk.mjs:1102:19) at injectInjectorOnly (_untracked-chunk.mjs:625:35) at ɵɵinject (_untracked-chunk.mjs:637:40) at inject2 (_untracked-chunk.mjs:646:10) at new _OAuthConfigurationHandler (abp-ng.oauth.mjs:147:20) at Object.OAuthConfigurationHandler_Factory [as factory] (abp-ng.oauth.mjs:157:14) at R3Injector.hydrate (_untracked-chunk.mjs:1301:33) at R3Injector.get (_untracked-chunk.mjs:1187:23)Line code: this.options = inject(CORE_OPTIONS);
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
- Your new error is the same root problem as the previous one, just surfacing at the next ABP package:
No provider found for InjectionToken CORE_OPTIONS(used by@abp/ng.oauth’sOAuthConfigurationHandler) means Angular is loading ABP code that tries toinject(CORE_OPTIONS)but the token instance that was provided byCoreModule.forRoot(...)is not the same token instance that@abp/ng.oauthis injecting.
In practice, this almost always happens when your workspace ends up with two physical copies / entry points of ABP Angular packages (or they’re resolved from the wrong place). Then:
CoreModule.forRoot()provides CORE_OPTIONS (copy A)@abp/ng.oauthinjects CORE_OPTIONS (copy B)
=> DI can’t find it → NG0201.
1) Fix package resolution (most important)
In an Nx / monorepo, check your
tsconfig.base.json(and any app-level tsconfig) for anypathsmapping that touches@abp/*or@volo/*or redirects modules to local sources.Apply this in the app tsconfig that builds/runs (or
tsconfig.base.json), so ABP always resolves fromnode_modules:{ "compilerOptions": { "paths": { "@abp/*": ["node_modules/@abp/*"], "@volo/*": ["node_modules/@volo/*"] } } }Then do a clean install:
rm -rf node_modules package-lock.json yarn.lock npm installThis addresses both the original
RestServiceissue and the currentCORE_OPTIONSissue (they’re symptoms of the same duplication/resolution problem).2) Keep
CoreModule.forRoot(...)in the root module only (you already did)Your updated
AppModuleimport order is fine. The key rule is:CoreModule.forRoot({ environment, registerLocaleFn })must be executed once (root module)- Other modules should not call
forRoot()again.
3) Angular version alignment
You mentioned “Angular 20” initially, but your
package.jsonshows Angular 21.0.0. Running ABP 10.2.0 with Angular 21 increases the chance of hitting build/runtime incompatibilities and dependency duplication issues. The safest route is to keep Angular at the version ABP 10.x templates target, or upgrade ABP packages to a version that officially targets your Angular major.(There isn’t a single “NgModule vs standalone” requirement here; the error is DI token duplication, not the bootstrap style.)
If you apply step (1) and clean reinstall,
CORE_OPTIONSshould resolve and the app should pass this startup stage.Sources:
- https://abp.io/docs/10.2/framework/ui/angular/http-requests
- https://abp.io/support/questions/10506
This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon.
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) - Your new error is the same root problem as the previous one, just surfacing at the next ABP package:
-
0
Hello,
You typically do not need to migrate your application to standalone, as module-based development is still supported. However, the issue you are experiencing may be related to configuration changes in
angular.json, particularly since we updated the builder to use the application builder.Additionally, with the upgrade to Angular version 21, some updates were made to
tsconfig.jsonto comply with newer TypeScript requirements. We also introduced zone-based change detection in the application providers:// app.module.ts // ... imports: [ /* ... */ ], providers: [provideZoneChangeDetection()] // ...You can find more details in the migration guide: https://abp.io/docs/latest/release-info/migration-guides/abp-10-1#angular-version-upgraded-to-v21
If your application already reflects these changes and the issue persists, please feel free to share a minimal reproducible example: https://stackoverflow.com/help/minimal-reproducible-example
You can send it to my email at sumeyye.kurtulus@volosoft.com, or alternatively provide more details about your configuration.
Thank you for your cooperation.
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)