NgModule not found in ionic 2 app?

This part is confusing, and I only figured out through trial and error. Being a newbie to Typescript, Ionic 2, and Angular 2, I’ve been doing a lot of reading. What I’ve found in the Angular 2 docs is that you should be creating modules for features of your code. The Angular docs recommend that you bootstrap a root module that contains everything for your project.

Naturally, I tried this with Ionic2, but quickly ran into errors with providers, among other things. Turns out that I need to set all my providers on a root component for it to work in Ionic2.

At first when I was doing this import { NgModule } from '@angular/core' I would get an error that NgModule was not present. I ignored it, thinking that it was Visual Studio intellisense error. Only after many hours of debugging, reading, and trial and error I have come to the conclusion that Ionic 2 includes a version of Angular 2 that doesn’t have NgModules (unless their hidden somewhere else).

Not sure why this isn’t mentioned in the Ionic 2 documentation. Seems important enough to me. Probably save someone else a lot of pain too.

Anyone have any explanation for this?

1 Like

Bump…Anyone have any thoughts?

Hi @mtycholaz
Ionic 2 is actually based on Angular 2 RC4, NgModule are a new feature of Angular RC5

2 Likes

Well this clears it up a lot. So I’ve been reading Angular RC5 documents, and programming in RC4. I wonder why they’re adding new features in a Release Candidate phase. Seems risky to me.

The blog says it NgModule should be supported now, any suggestion how to fix this?

Hi GuyL,

You should you upgrade your application to Ionic 2.0.0-rc.2

I often take this package.json as a reference for updating my Ionic apps.

I hope this help !

Thanks for the reply.
I did what you suggested, and now I get the following build error:

npm ERR! code EPEERINVALID
npm ERR! peerinvalid The package rxjs does not satisfy its siblings’ peerDependencies requirements!
npm ERR! peerinvalid Peer @angular/core@2.1.1 wants rxjs@5.0.0-beta.12