Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ionic generate page error: Could not find your routes file

I'm having trouble generating a new page in Ionic (Angular). Here's the command I used and the error I received:

$ ionic g page mypage
> ng generate page mypage --project=app
Could not find your routes file. Use the skip-import option to skip importing.
[ERROR] Could not generate page.

I've also tried using --skip-import but got an "Unknown argument" error. How can I resolve this to successfully generate a new page?

like image 651
Rens Jaspers Avatar asked Jun 12 '26 09:06

Rens Jaspers


2 Answers

Turns out that my project is using NgModules but my Ionic CLI was somehow configured to use standalone components in angular.json.

I had to change projects.app.schematics.@ionic/angular-toolkit:page.standalone from true to false. This resolved the issue.

Example:

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "app": {
      "projectType": "application",
      "schematics": {
        "@ionic/angular-toolkit:page": {
          "styleext": "scss",
          "standalone": false
        }
      },
...
like image 147
Rens Jaspers Avatar answered Jun 13 '26 23:06

Rens Jaspers


I had the same problem, I added "standalone" : true not in projects.app.schematics but in the root schematics. example:

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "app": {
      "projectType": "application",
      "schematics": {},  // -- here empty
...

  },
  "cli": {
    "schematicCollections": [
      "@ionic/angular-toolkit"
    ]
  },
  "schematics": {
    "@ionic/angular-toolkit:component": {
      "styleext": "scss"
    },
    "@ionic/angular-toolkit:page": {
      "styleext": "scss",
      "standalone": true  // ++ add here
    }
  }
}
like image 24
Pavel Zaydulin Avatar answered Jun 13 '26 23:06

Pavel Zaydulin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!