ng g c <name> --skip-import

Add the --skip-import option.
Reason: It will skip new component entry in the module.

encountered the same issue when I was creating a component within a specific feature (or project). And I realized I had to get into the app directory.

"Error: Could not find an NgModule for the new component. Use the skip-import option to skip importing components in NgModule. Could not find an NgModule for the new component. Use the skip-import option to skip importing components in NgModule"


because of new SPA templates. we had the same problem and solved it by installing "Angular files" extension for VS Code. It generates needed files from the context menu. then just need to add Component in app.module.shared.ts

ended up totally deleting node_modules, clearing out the yarn cache and then running yarn to reinstall all packages. I also edited my angular.json file so that my pathing looked like this for all applications and libraries:

"root": "libs/my-lib",

Change root to the directory where your module is in angular.json

From:

root:""

to directory of app module:

root: "/src/app"

If you still have Problems with this Issue, check the following:

1. File need to be present:

app-routing.module.ts

2. Angular default Project need to be app

"projects": {
        "app": {

3. angular.json need to have the following content:

"cli": {
        "defaultCollection": "@ionic/angular-toolkit",
        "analytics": false
    },
    "schematics": {
        "@ionic/angular-toolkit:component": {
            "styleext": "scss"
        },
        "@ionic/angular-toolkit:page": {
            "styleext": "scss"
        }
    }

4. Ionic angular Toolkit need to be installed

"@ionic/angular-toolkit"

5. ionic.config.json file need to be in the root of the project

{
    "name": "project",
    "type": "angular",
    "id": ""
}