Open Closed

Angular 20 Upgrade – NG0201: No provider found for RestService (abp-ng.core) #10558


User avatar
0
imranStem created

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

Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

5 Answer(s)
  • User Avatar
    0
    AI-Bot created
    Support Team ABP Agent
    • You do not need to migrate to standalone (bootstrapApplication) just to fix this. ABP Angular packages still work with NgModule-based apps.
    • RestService is already provided in root, so NG0201: No provider found for RestService typically 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 by AppModule (directly or through your AbpModule) and make sure it is not imported again elsewhere.

    Your AbpModule approach is OK, but make sure other feature/shared modules don’t import CoreModule again (they should import CoreModule without forRoot, or not import it at all if not needed).

    2) Fix common Angular 20 + ABP DI “no provider” cause: TS paths overriding @abp/*

    After upgrades, a very common reason for ABP DI tokens/providers not being found is that your tsconfig*.json contains paths mappings that cause @abp/* (and/or @volo/*) to resolve to something other than node_modules (e.g., a local projects/* 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.json or apps/<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 start
    

    This ensures Angular resolves @abp/ng.core from the installed package (where RestService is 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)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Hi,

    Thanks for the detailed report. Before suggesting a fix, could you share the output of:

    npm list @abp/ng.core
    

    The reason is: the error "No provider found for RestService" is unusual — in newer ABP versions RestService is providedIn: '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 AppModule that should be fixed regardless:

    @NgModule({
      imports: [
        AbpModule,
        BrowserModule,
        BrowserAnimationsModule,
        AppRoutingModule,
        // HttpClientModule,  ← remove this
      ],
    })
    export class AppModule {}
    

    HttpClientModule (old API) should be removed. ABP's CoreModule.forRoot() already sets up HttpClient internally via provideHttpClient(). 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 AbpModule wrapper 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)
  • User Avatar
    0
    imranStem created

    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 deduped
    

    Packages

    "@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 modules
    

    After 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)
  • User Avatar
    0
    AI-Bot created
    Support Team ABP Agent
    • 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’s OAuthConfigurationHandler) means Angular is loading ABP code that tries to inject(CORE_OPTIONS) but the token instance that was provided by CoreModule.forRoot(...) is not the same token instance that @abp/ng.oauth is 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.oauth injects 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 any paths mapping 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 from node_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 install
    

    This addresses both the original RestService issue and the current CORE_OPTIONS issue (they’re symptoms of the same duplication/resolution problem).

    2) Keep CoreModule.forRoot(...) in the root module only (you already did)

    Your updated AppModule import 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.json shows 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_OPTIONS should 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)
  • User Avatar
    0
    sumeyye.kurtulus created
    Support Team Angular Expert

    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.json to 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)
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.8.0-preview. Updated on September 28, 2026, 11:44
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.