Could not find an NgModule. Use the skip-import option to skip importing in NgModule. [ERROR] Could not generate page

I start a new app and I tried to generate a new page. and I couldn’t because the following error is showing

Could not find an NgModule. Use the skip-import option to skip importing in NgModule.
[ERROR] Could not generate page.
1 Like

Finally found a solution

I had to go to src/app and run the command.


ionic generate page pages/first

then It worked as before

1 Like

Thank you for this solution
When I do this, it get the new folder in the main of the folder, not in the subfolders src/app

I need to enter src/app/name to create the page name in the right folder

Ionic version
6.11.1

2 Likes

use ng g c my-test/paper and import this component in module

yeah I’m also having the same issue due to this new version. But routing was generating fine.

Hi, can you explain little bit more?

it is a bug in the current version of the ionic logo and must be corrected.

this should work by the hour …
ionic g page src/app/pages/{name-of-your-page}

Hi, is the bug fixed?

yes update to latest version
npm i @ionic/angular-toolkit@2.3.3 --save-dev

1 Like

This was a bug in ionic v6. Now it seems to be fixed. :relieved: :relieved: :relieved:

Will let this be in the forum for anyone who is struggling with this issue.

thx. thats its the solution to back to normality :slightly_smiling_face:

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": ""
}

2 Likes

this fix the issue for me. I would have upvoted this if I could.

In 2024+, newer versions of Angular use standalone components by default. If you try to add ionic to an existing project, you will get this error as it try to use modules.

Make sure your schematics specify standalone for the schematics to avoid the NgModule import error.

"schematics": {
    "@ionic/angular-toolkit:component": {
      "styleext": "scss",
      "standalone": true
    },
    "@ionic/angular-toolkit:page": {
      "styleext": "scss",
      "standalone": true
    }
  }