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
source to share
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.
- Remove link to
ionic-native
frompackage.json
. - 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';
-
Add
StatusBar
alsoSplashScreen
to the array of providersapp.module.ts
-
Update imports in
StatusBar
andSplashScreen
inapp.component.ts
(same as step # 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.
source to share