IONIC 2 - Runtime error. Cannot find module "ionic"

I am getting this error while doing ionic 2:

Mistake

Execution error. Cannot find module "ionic".

Stack

d @LOCALHOST: 8100 / build / polyfills.js: 3: 7138 LOCALHOST: 8100 / build / main.js: 113219: 16 webpack_require @LOCALHOST: 8100 / build / main.js: 20: 34 LOCALHOST: 8100 / build / main .js: 87074: 92 webpack_require @LOCALHOST: 8100 / assemblies / main.js: 20: 34 LOCALHOST: 8100 / assemblies / main.js: 135215: 89 webpack_require @LOCALHOST: 8100 / assemblies / main.js: 20:34 localhost : 8100 / build / main.js: 66: 37 global Code @ local: 8100 / build / main.js: 67: 12

+3


source to share


4 answers


Install below



npm install ionic-native --save

+10


source


The problem might be due to ionic package update. Delete the node_modules folder.

Ionic packs changed from Ionic 2.x to 3.x. You need to make the following changes.

  1. Remove link to ionic-native

    from package.json

    .

  2. Install custom ionic 3.x packages using the following commands

npm install @ ionic-native / core --save

npm install @ ionic-native / splash screen --save

npm install @ ionic-native / @ ionic-native / status bar --save


3. Change the links to the native ionic 2.x package from app.module.ts

.

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

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




  1. Add StatusBar

    also SplashScreen

    to the array of providersapp.module.ts


  2. Update imports in StatusBar

    and SplashScreen

    in app.component.ts

    (same as step # 3)

  3. Add the following to the constructor app.component.ts

statusBar: StatusBar, splash screen: splash screen


7. If you are using a service http

, import it app.module.ts

as app.module.ts

below:

import {HttpModule} from '@ angular / http';

Add HttpModule

to array HttpModule

.

Note. You may need to do the same for other similar packages.

+4


source


Run the following command to install Ionic Native

into your project:

npm install @ionic-native --save

      

0


source


I solved this error by changing this:

import { NavController } from 'ionic-angular/umd'

      

to that:

import { NavController } from 'ionic-angular'

      

0


source







All Articles