3

I'm trying to connect ionic 2 app to backand and getting this run time error:

Cannot find module "ionic-native".

I have tried running npm install @ionic-native/core --save – but does not help. Many thanks

Set Up Details Are Here: Ionic Framework: 3.0.1 Ionic App Scripts: 1.3.0 Angular Core: 4.0.0 Angular Compiler CLI: 4.0.0 Node: 6.10.1 OS Platform: Windows 10 Navigator Platform: Win32 User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36

Error: Cannot find module "ionic-native" at g (localhost:8100/build/polyfills.js:3:7133) at Object.module.exports (localhost:8100/build/main.js:114616:7) at webpack_require (localhost:8100/build/main.js:20:30) at Object. (localhost:8100/build/main.js:86362:73) at webpack_require (localhost:8100/build/main.js:20:30) at Object. (localhost:8100/build/main.js:140153:70) at webpack_require (localhost:8100/build/main.js:20:30) at localhost:8100/build/main.js:66:18

Package.Json as follows:

{
  "name": "ionic-hello-world",
  "author": "Ionic Framework",
  "homepage": "http://ionicframework.com/",
  "private": true,
  "scripts": {
    "clean": "ionic-app-scripts clean",
    "build": "ionic-app-scripts build",
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve"
  },
  "dependencies": {
    "@angular/common": "4.0.0",
    "@angular/compiler": "4.0.0",
    "@angular/compiler-cli": "4.0.0",
    "@angular/core": "4.0.0",
    "@angular/forms": "4.0.0",
    "@angular/http": "4.0.0",
    "@angular/platform-browser": "4.0.0",
    "@angular/platform-browser-dynamic": "4.0.0",
    "@ionic-native/core": "3.4.2",
    "@ionic-native/splash-screen": "3.4.2",
    "@ionic-native/status-bar": "3.4.2",
    "@ionic/storage": "2.0.1",
    "ionic-angular": "3.0.1",
    "ionicons": "3.0.0",
    "rxjs": "5.1.1",
    "socket.io-client": "^1.7.3",
    "sw-toolbox": "3.4.0",
    "zone.js": "^0.8.4"
  },
  "devDependencies": {
    "@ionic/app-scripts": "1.3.0",
    "@types/node": "7.0.13",
    "@types/socket.io-client": "1.4.29",
    "typescript": "~2.2.1"
  },
  "cordovaPlugins": [
    "cordova-plugin-whitelist",
    "cordova-plugin-statusbar",
    "cordova-plugin-console",
    "cordova-plugin-device",
    "cordova-plugin-splashscreen",
    "ionic-plugin-keyboard",
    "cordova-plugin-inappbrowser"
  ],
  "cordovaPlatforms": [],
  "description": "myApp: An Ionic project"
}
Sampath
  • 63,341
  • 64
  • 307
  • 441
  • I'm not sure what you will need to see, but any help appreciated – Elliot Gilford Apr 20 '17 at 21:02
  • Can you show your `package.json` file? Never put your question on the comment section.Please remove that and put that with your original post. – Sampath Apr 20 '17 at 21:29
  • Hi, it wouldn't let me paste all of it in the original comment because it has links in it apparently. Quite new to using stackoverflow. How do I get the package.json file? I realise this is a bit of a rookie question probably – Elliot Gilford Apr 20 '17 at 21:38
  • This is sample `package.json` file? So what is your one? https://github.com/driftyco/ionic-conference-app/blob/master/package.json – Sampath Apr 20 '17 at 22:00
  • Thanks Sampath, have added it into the question – Elliot Gilford Apr 23 '17 at 01:34

2 Answers2

1

This issue is associated with the old import 'ionic-native'

in my case : import { StatusBar, Splashscreen } from 'ionic-native'; I removed and added the new :

https://ionicframework.com/docs/native/status-bar https://ionicframework.com/docs/native/splash-screen

If this is also your case, do not forget to add also in the module provider

niojihye
  • 11
  • 1
0

With Ionic 3, the ionic-native modules are now loaded as providers. See below links:

https://github.com/driftyco/ionic/blob/master/CHANGELOG.md

http://blog.ionic.io/ionic-native-3-x/

https://github.com/driftyco/ionic-conference-app/commit/62088

So, you have to upgrade your code if you want to use any of the native features.

Prerak Tiwari
  • 3,436
  • 4
  • 34
  • 64