MTA
MTA

Reputation: 1073

ionic: module has no exported member

I am a newbie of ionic framework, just started now. I am working on windows. I created my app with this command:

ionic start ionic-welcome tabs
ionic serve

I create a new page with below command

ionic g page welcome

I get this response in my console:

[OK] Generated a page named welcome!

updated app.module.ts for welcome page:

import { NgModule, ErrorHandler } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { IonicApp, IonicModule, IonicErrorHandler } from 'ionic-angular';
import { MyApp } from './app.component';

import { Welcome } from '../pages/welcome/welcome';
import { AboutPage } from '../pages/about/about';
import { ContactPage } from '../pages/contact/contact';
import { HomePage } from '../pages/home/home';
import { TabsPage } from '../pages/tabs/tabs';

import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';

@NgModule({
  declarations: [
    MyApp,
    Welcome,
    AboutPage,
    ContactPage,
    HomePage,
    TabsPage
  ],
  imports: [
    BrowserModule,
    IonicModule.forRoot(MyApp)
  ],
  bootstrap: [IonicApp],
  entryComponents: [
    MyApp,
    Welcome,
    AboutPage,
    ContactPage,
    HomePage,
    TabsPage
  ],
  providers: [
    StatusBar,
    SplashScreen,
    {provide: ErrorHandler, useClass: IonicErrorHandler}
  ]
})
export class AppModule {}

But when i browse to localhost:8100 i am getting this error for "welcome page".

Module '"C:/xampp/htdocs/ionic/ionic-welcome/src/pages/welcome/welcome"' has no exported member 'Welcome'.

package.json:

{
  "name": "ionic-welcome",
  "version": "0.0.1",
  "author": "Ionic Framework",
  "homepage": "http://ionicframework.com/",
  "private": true,
  "scripts": {
    "clean": "ionic-app-scripts clean",
    "build": "ionic-app-scripts build",
    "lint": "ionic-app-scripts lint",
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve"
  },
  "dependencies": {
    "@angular/common": "4.1.3",
    "@angular/compiler": "4.1.3",
    "@angular/compiler-cli": "4.1.3",
    "@angular/core": "4.1.3",
    "@angular/forms": "4.1.3",
    "@angular/http": "4.1.3",
    "@angular/platform-browser": "4.1.3",
    "@angular/platform-browser-dynamic": "4.1.3",
    "@ionic-native/core": "3.12.1",
    "@ionic-native/splash-screen": "3.12.1",
    "@ionic-native/status-bar": "3.12.1",
    "@ionic/storage": "2.0.1",
    "ionic-angular": "3.6.0",
    "ionicons": "3.0.0",
    "rxjs": "5.4.0",
    "sw-toolbox": "3.6.0",
    "zone.js": "0.8.12"
  },
  "devDependencies": {
    "@ionic/app-scripts": "2.1.3",
    "typescript": "2.3.4"
  },
  "description": "An Ionic project"
}

Some says to remove '^' character from package.json but don't have one. I am out of options don't know what to do next, please help. enter image description here

Upvotes: 3

Views: 24312

Answers (1)

Ismail S
Ismail S

Reputation: 144

if you check Welcome.ts you probably find something like this

export class WelcomePage {

constructor(public navCtrl: NavController, public navParams: NavParams)
{
}

ionViewDidLoad() {
console.log('ionViewDidLoad WelcomePage');
}

in your app.modules.ts do the following

import { WelcomePage } from '../pages/welcome/welcome'

then add WelcomePage to declarations and entryComponents.

i just faced this problem and managed to solve it this way.

Good luck

Upvotes: 11

Related Questions