Skip to content

ng generate component return error #31362

@HarryVu176

Description

@HarryVu176

Command

generate

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

No response

Description

Hi, last week I was using ng generate and there wasn't any problems.

Today, when I'm running
ng g c [component_name]
I got this error: "Could not find an NgModule. Use the '--skip-import' option to skip importing in NgModule."

So I tried to run this
ng g c --standalone [component_name]
It generates successfully, however the component now coming with suffixes.

Minimal Reproduction

Run:
ng g c [component_name]
Error: "Could not find an NgModule. Use the '--skip-import' option to skip importing in NgModule."

ng g c --standalone [component_name]
It generates successfully, however the component now coming with suffixes.

Exception or Error


Your Environment

Angular CLI: 20.3.3
Node: 22.19.0
Package Manager: npm 11.1.0
OS: win32 x64


Angular: 20.2.4
... common, compiler, compiler-cli, core, forms
... platform-browser, router

Package                      Version
------------------------------------
@angular-devkit/architect    0.2002.2
@angular-devkit/core         20.2.2
@angular-devkit/schematics   20.3.3
@angular/build               20.2.2
@angular/cdk                 20.2.2
@angular/cli                 20.3.3
@angular/material            20.2.2
@schematics/angular          20.3.3
rxjs                         7.8.2
typescript                   5.9.2

Anything else relevant?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions