Ionic 3 generated page throws error

after doing an ionic start test blank --v3 and an ionic generate page AppDetails, I get this error:

Typescript Error
Property ‘forChild’ does not exist on type ‘typeof IonicModule’.
src/pages/app-details/app-details.module.ts
imports: [
IonicModule.forChild(AppDetailsPage),
],
Ionic Framework: 3.0.0
Ionic App Scripts: 1.3.0
Angular Core: 4.0.0
Angular Compiler CLI: 4.0.0
Node: 7.2.1
OS Platform: macOS Sierra
Navigator Platform: MacIntel
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36

please help me fix this error. thanks

Change that IonicModule to IonicPageModule.

2 Likes

that did the trick. thank you good sir. much appreciated

Cannot find name ‘IonicPageModule’.

1 Like

Did you generate the page using ionic g page AppDetails? I think I have the same problem right now…

@rapropos Is there a bug for the CLI already for this?

GitHub’s search functIon must be broken, because there are several. I’m still not sure what the intended behavior is here: whether they want to roll the IonicPageModule functionality into IonicModule or not.

Am I too dumb to search? Issues · ionic-team/ionic-cli · GitHub

To get ionic g page working with a newly installed project I had to change it to IonicPageModule, so I guess so…

That probably came out wrong. I wasn’t intending that at you, but rather at all the people who filed dupes.

No seriously, I can’t find them :blush: Check the link I posted… Probably in some other Repo…

main #11076 has a PR.

1 Like

Huh, interesting that this comes out of the main Ionic repo. Too complicated for me. +1 on the issues and PR.

Disclaimer: I am brand new to Ionic - like 12 hours experience playing with sample projects, and that’s it.

So let me get this straight: the command to generate a page (ionic g page SecondPage) generates code that is broken? That seems… bad. But okay, whatever, I can rename IonicModule -> IonicPageModule.

But then what do I import in my app.module.ts file? import { SecondPage } from ‘…/pages/second/second’; does not work - (has no exported member ‘SecondPage’). Okay… if I delete the second.module.ts file entirely, and make second.ts look like home.ts, then I can import SecondPage just fine. Is this bad? Should I learn how to use the Module? I have literally no idea what the benefits would be.

I don’t know, I’m just trying to follow along with online video tutorials, and I’m annoyed that built in code generation commands make buggy files.

2 Likes