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
}
},
...