angular: ng new does not generate app.module.ts in the src root folder Angular CLI 17.0.0

Command

new

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

v16.0.5

Description

I ran the command “ng new my-blog --routing --style=scss” to create a new angular project using Angular CLI version 17.0.0 and could not find the app.module.ts file automatically generated by the CLI.

In the documentation “https://angular.io/guide/file-structure” it says

app/app.module.ts | Defines the root module, named AppModule, that tells Angular how to assemble the application. Initially declares only the AppComponent. As you add more components to the app, they must be declared here. This file is not generated when using --no-standalone option.

I did not use the --no-standalone option so I was expecting this file to be generated by Angular CLI v17.0.0. Is this something new to be added by developer going forward.

Minimal Reproduction

ng new my-blog --routing --style=scss
? Do you want to enable Server-Side Rendering (SSR) and Static Site Generation (SSG/Prerendering)? No
CREATE my-blog/README.md (1060 bytes)
CREATE my-blog/.editorconfig (274 bytes)
CREATE my-blog/.gitignore (548 bytes)
CREATE my-blog/angular.json (2771 bytes)
CREATE my-blog/package.json (1038 bytes)
CREATE my-blog/tsconfig.json (909 bytes)
CREATE my-blog/tsconfig.app.json (263 bytes)
CREATE my-blog/tsconfig.spec.json (273 bytes)
CREATE my-blog/.vscode/extensions.json (130 bytes)
CREATE my-blog/.vscode/launch.json (470 bytes)
CREATE my-blog/.vscode/tasks.json (938 bytes)
CREATE my-blog/src/main.ts (250 bytes)
CREATE my-blog/src/favicon.ico (15086 bytes)
CREATE my-blog/src/index.html (292 bytes)
CREATE my-blog/src/styles.scss (80 bytes)
CREATE my-blog/src/app/app.component.scss (0 bytes)
CREATE my-blog/src/app/app.component.html (20887 bytes)
CREATE my-blog/src/app/app.component.spec.ts (919 bytes)
CREATE my-blog/src/app/app.component.ts (369 bytes)
CREATE my-blog/src/app/app.config.ts (227 bytes)
CREATE my-blog/src/app/app.routes.ts (77 bytes)
CREATE my-blog/src/assets/.gitkeep (0 bytes)
✔ Packages installed successfully.

Exception or Error

No response

Your Environment

ng version

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 17.0.0
Node: 20.9.0
Package Manager: npm 10.1.0
OS: darwin x64

Angular: 
... 

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.1700.0 (cli-only)
@angular-devkit/core         17.0.0 (cli-only)
@angular-devkit/schematics   17.0.0 (cli-only)
@schematics/angular          17.0.0 (cli-only)

Anything else relevant?

No response

About this issue

  • Original URL
  • State: closed
  • Created 8 months ago
  • Comments: 15 (3 by maintainers)

Most upvoted comments

@lati57 You can use the following command to generate a project that has app.module.ts and app-routing.module.ts:

ng new my-app --no-standalone --routing --ssr=false

This is expected as now standalone applications are the default.

We should update the docs, as this file is only generated when using no-standalone.

@Vaishnavi-ambati missing some context here, but I assume you created a standalone project but want to use modules.

run this command to create a new project: ng new my-app --no-standalone --routing --ssr=false and copy over any code you’ve already written in the other project. There is no automatic way to convert projects and if you just realize that app.module.ts is missing, you probably haven’t written much code anyway.

In the future and for other people finding this issue: please do not ask questions here. The issue is closed and issues are not intended for asking questions about your projects. We have a discord with helpful people willing to answer your questions: discord.gg/angular

Thanks for the info. I will use --no–standalone to generate the app module.

@ProgammingGuy Please read the comment above yours, it answers your question. Alternatively, give standalone a try as it’s the modern way of writing Angular apps: https://angular.dev/tutorials

@twerske Is there a way to lock this issue for new comments? The question about missing app.module.ts has been answered in this issue, and the Angular Discord is a better place to provide support for questions related to personal projects.

@millerraycell feel free to open a PR !