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?
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
}
},
...
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
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With