Skip to content
Advertisement

ionic serve gives error in Chrome: Illegal constructor in CreateClass in core.js

I have recently taken over an Ionic project and working on getting it to work. The project runs on device, but I’m trying to get it to work in browser as well.

I have updated to the newest versions for plugins and dependencies, but now I’m stuck on a strange javascript error in Chrome console. After this error appeared, the app on device is also just white after the spalsh screen. I guess this is the same javascript error.

First I got this: enter image description here

Then, following this answer, I got rid of the error, but got a new one which I cant for the life of me figure out of. Cant find anyone having the same issue either.

This is what I see in the console when running ‘ionic serve’:

Errors in Chrome console

Please help if you know what can cause this! How can I get rid of this error and get the app to run?

EDIT: I think maybe it can have something to do with the app.module code:

import { NgModule } from '@angular/core';
import { IonicApp, IonicModule } from 'ionic-angular';
import { IonicStorageModule } from '@ionic/storage';
import { LongPress } from '../components/long-press/long-press';
import { MyApp } from './app.components';
import { BrowserModule } from '@angular/platform-browser';

import { AboutPage } from '../pages/about/about';
import { AddSkypeUserPage } from '../pages/add-skype-user/add-skype-user';
import { ContactPage } from '../pages/contact/contact';
import { DagsVisningPage } from '../pages/dags-visning/dags-visning';
import { HomePage } from '../pages/home/home';
import { InnstillingerPage } from '../pages/innstillinger/innstillinger';
import { LoginPage } from '../pages/login/login';
import { NyAktivitetPage } from '../pages/ny-aktivitet/ny-aktivitet';
import { CameraPopoverPage } from '../pages/ny-aktivitet/camera-popover';
import { ScoreboardPage } from '../pages/scoreboard/scoreboard';
import { TabsPage } from '../pages/tabs/tabs';
import { UkesplanleggerPage } from '../pages/ukesplanlegger/ukesplanlegger';

@NgModule({
  declarations: [
    LongPress,
    MyApp,
    AboutPage,
    AddSkypeUserPage,
    ContactPage,
    DagsVisningPage,
    HomePage,
    InnstillingerPage,
    LoginPage,
    NyAktivitetPage,
    CameraPopoverPage,
    ScoreboardPage,
    TabsPage,
    UkesplanleggerPage
  ],
  imports: [
    IonicModule.forRoot(MyApp),
    IonicStorageModule.forRoot(),
    BrowserModule
  ],
  bootstrap: [IonicApp],
  entryComponents: [
    MyApp,
    AboutPage,
    AddSkypeUserPage,
    ContactPage,
    DagsVisningPage,
    HomePage,
    InnstillingerPage,
    LoginPage,
    NyAktivitetPage,
    CameraPopoverPage,
    ScoreboardPage,
    TabsPage,
    UkesplanleggerPage
  ],
  providers: []
})
export class AppModule {}

Thanks!

Advertisement

Answer

Finally found the stupid problem by removing bits of code part by part!

It was due to the change of Storage to IonicStorageModule.

If you experience the same, you should add:

import { IonicStorageModule } from "@ionic/storage";

and:

imports: [
    IonicModule.forRoot(MyApp),
    BrowserModule,
    IonicStorageModule.forRoot()
  ],

to your app.module.ts, but keep using:

import { Storage } from '@ionic/storage';

in your other classes.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement