Skip to content

ng generate application produces wrong import path for AppRoutingModule (uses ./app-routing-module instead of ./app-routing.module) #30497

Closed

Description

@dev-bretta

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

compiler-cli

Is this a regression?

Yes

Description

I am running a monorepo of websites/applications

When running:

ng generate application application-name \
  --experimental-zoneless=true \
  --inline-style=true \
  --inline-template=true \
  --minimal=true \
  --ssr=true \
  --standalone=false \
  --strict=true \
  --style=css

the import within the app-module.ts for AppRoutingModule is:
import { AppRoutingModule } from './app-routing-module';

and not: 
import { AppRoutingModule } from './app-routing.module';

Found in version 20.0.0, updated to 20.0.2 and still present. 

### Please provide a link to a minimal reproduction of the bug

_No response_

### Please provide the exception or error you saw

```true

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

Angular CLI: 20.0.1
Node: 22.16.0
Package Manager: npm 10.9.2
OS: linux x64

Angular: 20.0.2
... animations, cdk, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, platform-server
... router

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.2000.1
@angular-devkit/core         20.0.1
@angular-devkit/schematics   20.0.1
@angular/build               20.0.1
@angular/cli                 20.0.1
@angular/ssr                 20.0.1
@schematics/angular          20.0.1
ng-packagr                   20.0.0
rxjs                         7.8.2
typescript                   5.8.3
zone.js                      0.15.1

Anything else?

No response

Activity

  1. dev-bretta commented on Jun 9, 2025

    @dev-bretta
    Author

    On top of this, I have just realised that there are two app-modules.

    One app-module.ts that contains:

    `import { NgModule, provideBrowserGlobalErrorListeners, provideZonelessChangeDetection } from '@angular/core';
    import { BrowserModule, provideClientHydration, withEventReplay } from '@angular/platform-browser';

    import { AppRoutingModule } from './app-routing-module';
    import { App } from './app';

    @NgModule({
    declarations: [
    App
    ],
    imports: [
    BrowserModule,
    AppRoutingModule
    ],
    providers: [
    provideBrowserGlobalErrorListeners(),
    provideZonelessChangeDetection(),
    provideClientHydration(withEventReplay())
    ],
    bootstrap: [App]
    })
    export class AppModule { }
    `

    and a second properly formatted path app.module.ts that contains:

    `import { NgModule } from '@angular/core';

    import { AppRoutingModule } from './app-routing.module';

    @NgModule({
    declarations: [],
    imports: [,
    AppRoutingModule
    ]
    })
    export class AppModule { }

  2. transferred this issue fromangular/angularon Jun 9, 2025
  3. alan-agius4 commented on Jun 10, 2025

    @alan-agius4
    Collaborator

    I’m unable to reproduce this issue. It's surprising, considering that the --experimental-zoneless option is no longer available in version 20, and running ng generate application with it should result in a failure.

    $ ng generate application application-name  --experimental-zoneless=true --inline-style=true --inline-template=true  --minimal=true --ssr=true --standalone=false --strict=true --style=css
    
    Error: Unknown argument: experimental-zoneless
    

    Could you run the following command and share the output?

    npm ls @schematics/angular
    
  4. added
    needs: more info
    on Jun 10, 2025
  5. dev-bretta commented on Jun 10, 2025

    @dev-bretta
    Author

    My apologies I used --zoneless=false

  6. alan-agius4 commented on Jun 10, 2025

    @alan-agius4
    Collaborator

    I am not seeing an app.module.ts being created. Can you please share the output of npm ls @schematics/angular?

  7. dev-bretta commented on Jun 10, 2025

    @dev-bretta
    Author

    @angular/[email protected]
    └── @schematics/[email protected]

  8. dev-bretta commented on Jun 10, 2025

    @dev-bretta
    Author

    Console Output:

    ng generate application application-name \
      --zoneless=true \
      --inline-style=true \
      --inline-template=true \
      --minimal=true \
      --ssr=true \
      --standalone=false \
      --strict=true \
      --style=css
    CREATE websites/application-name/src/app/app-routing.module.ts (245 bytes)
    CREATE websites/application-name/src/app/app.module.ts (203 bytes)
    CREATE websites/application-name/src/app/app.component.ts (196 bytes)
    CREATE websites/application-name/src/main.ts (198 bytes)
    CREATE websites/application-name/src/app/app-module.ts (594 bytes)
    CREATE websites/application-name/src/app/app.ts (256 bytes)
    CREATE websites/application-name/tsconfig.app.json (455 bytes)
    CREATE websites/application-name/public/favicon.ico (15086 bytes)
    CREATE websites/application-name/src/index.html (301 bytes)
    CREATE websites/application-name/src/styles.css (80 bytes)
    CREATE websites/application-name/src/main.server.ts (70 bytes)
    CREATE websites/application-name/src/app/app.module.server.ts (389 bytes)
    CREATE websites/application-name/src/app/app.routes.server.ts (166 bytes)
    CREATE websites/application-name/src/server.ts (1563 bytes)
    UPDATE angular.json (27478 bytes)
    UPDATE tsconfig.json (1282 bytes)
    UPDATE package.json (1806 bytes)
    ✔ Packages installed successfully.
    

    Image

    Image

    Image

  9. dev-bretta commented on Jun 10, 2025

    @dev-bretta
    Author

    workspace setup command is:

    This was run in version 19

    ng new workspace-name --no-create-application --zoneless=true --inline-style=true --inline-template=true --minimal=true --new-project-root=websites --skip-test=true --ssr=true --standalone=false --style=css

  10. alan-agius4 commented on Jun 10, 2025

    @alan-agius4
    Collaborator

    @brettaio, I was able to replicate the issue when generating the workspace using Angular CLI version 19.

  11. added
    freq1: low
    and removed
    needs: more info
    on Jun 10, 2025
  12. added theissue type on Jun 10, 2025
  13. dev-bretta commented on Jun 10, 2025

    @dev-bretta
    Author

    I've cleared node_modules and install with the current setup - same bug

    "@angular/animations": "^20.0.2",
        "@angular/cdk": "^20.0.2",
        "@angular/common": "^20.0.2",
        "@angular/compiler": "^20.0.2",
        "@angular/core": "^20.0.2",
        "@angular/forms": "^20.0.2",
        "@angular/platform-browser": "^20.0.2",
        "@angular/platform-browser-dynamic": "^20.0.2",
        "@angular/platform-server": "^20.0.2",
        "@angular/router": "^20.0.2",
        "@angular/ssr": "^20.0.1",
        "@netlify/angular-runtime": "^2.2.2",
        "@tailwindcss/cli": "^4.0.14",
        "@tailwindcss/postcss": "^4.0.7",
        "express": "^5.1.0",
        "postcss": "^8.5.3",
        "rxjs": "~7.8.0",
        "stripe": "^18.0.0",
        "tailwindcss": "^4.0.14",
        "tslib": "^2.3.0",
        "zone.js": "~0.15.0"
    
  14. added a commit that references this issue on Jun 12, 2025
    c7c3976
  15. added 2 commits that reference this issue on Jun 12, 2025
    4be58ee
    5c48b8e
  16. dev-bretta commented on Jun 17, 2025

    @dev-bretta
    Author

    Have update to latest and still having same issue

  17. dev-bretta commented on Jun 17, 2025

    @dev-bretta
    Author

    Angular CLI: 20.0.2
    Node: 22.16.0
    Package Manager: npm 10.9.2
    OS: linux x64

    Angular: 20.0.3
    ... animations, cdk, common, compiler, compiler-cli, core, forms
    ... platform-browser, platform-browser-dynamic, platform-server
    ... router

    Package Version

    @angular-devkit/architect 0.2000.2
    @angular-devkit/core 20.0.2
    @angular-devkit/schematics 20.0.2
    @angular/build 20.0.2
    @angular/cli 20.0.2
    @angular/ssr 20.0.2
    @schematics/angular 20.0.2
    ng-packagr 20.0.0
    rxjs 7.8.2
    typescript 5.8.3
    zone.js 0.15.1

  18. alan-agius4 commented on Jun 17, 2025

    @alan-agius4
    Collaborator

    This is not released yet. It will be on NPM later this week.

  19. angular-automatic-lock-bot commented on Jul 18, 2025

    @angular-automatic-lock-bot

    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.

  20. locked and limited conversation to collaborators on Jul 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: @schematics/angularfreq1: lowseverity5: regressiontype: bug/fix

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions