Error: Cannot find module "ionic-native" (yes: another one)


#1

I know that this toppic is very popular. But really: I reviewed every single post about this problem, but none of them is giving me a solution. (for instance: I made sure there are no references to the old “ionic-native” package).

So I keep getting: Cannot find module “ionic-native”

Below is a copy of my package.json. Can somebody spot a problem with it?
It would be really appreciated!!

{
“name”: “birdyPro”,
“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.0”,
"@angular/compiler": “4.1.0”,
"@angular/compiler-cli": “4.1.0”,
"@angular/core": “4.1.0”,
"@angular/forms": “4.1.0”,
"@angular/http": “4.1.0”,
"@angular/platform-browser": “4.1.0”,
"@angular/platform-browser-dynamic": “4.1.0”,
"@ionic-native/barcode-scanner": “^3.10.3”,
"@ionic-native/core": “^3.10.3”,
"@ionic-native/facebook": “^3.10.3”,
"@ionic-native/google-plus": “^3.10.3”,
"@ionic-native/splash-screen": “^3.7.0”,
"@ionic-native/status-bar": “^3.7.0”,
"@ionic-native/twitter-connect": “^3.10.3”,
"@ionic/storage": “2.0.1”,
"@types/howler": “^2.0.2”,
“angular2-jwt”: “^0.2.3”,
“angularfire2”: “^4.0.0-rc.0”,
“cordova-plugin-console”: “^1.0.5”,
“cordova-plugin-device”: “^1.1.4”,
“cordova-plugin-splashscreen”: “^4.0.3”,
“cordova-plugin-statusbar”: “^2.2.2”,
“cordova-plugin-whitelist”: “^1.3.1”,
“firebase”: “^4.0.0”,
“howler”: “^2.0.3”,
“ionic-angular”: “3.2.1”,
“ionic-plugin-keyboard”: “^2.2.1”,
“ionicons”: “3.0.0”,
“phonegap-plugin-barcodescanner”: “^6.0.6”,
“rxjs”: “5.1.1”,
“sw-toolbox”: “3.6.0”,
“zone.js”: “0.8.10”
},
“devDependencies”: {
"@ionic/app-scripts": “1.3.7”,
"@ionic/cli-plugin-cordova": “1.1.2”,
"@ionic/cli-plugin-ionic-angular": “1.1.2”,
“typescript”: “2.2.1”
},
“description”: “An Ionic project”,
“cordova”: {
“plugins”: {
“phonegap-plugin-barcodescanner”: {},
“cordova-plugin-whitelist”: {},
“cordova-plugin-console”: {},
“cordova-plugin-statusbar”: {},
“cordova-plugin-device”: {},
“cordova-plugin-splashscreen”: {},
“ionic-plugin-keyboard”: {}
}
}
}


#2

I have a hard time believing this. Use an automated tool like grep. I bet you have stale imports that are still referring to it.


#3

Hey, thanks for the fast reply!
But I’m sure! Used 2 different tools grep & VS Code.

The only reference that is found is in the “main.js.map” file:
import { BarcodeScanner } from ‘ionic-native’;

But in my code I updated everything (the main.js.map is referring to my old implementation!?):
import { BarcodeScanner } from ‘@ionic-native/barcode-scanner’;
and then using constructor injection…

Any idea?
Thx


#4

Try running npm run build --prod and then post the full error message - as text, not an image.


#5

maybe, try something dumb, run a “build” (ionic build android or ios), before trying another ionic serve. This might clean /
erase the cache of your previous Ionic builds.


#6

Thank you so much!!
I had to solve a dozen of other problems and finally my v2 app is working again with v3!

The important thing for me to remember is that “ionic serve” is giving the wrong error messages, so from now on I’ll use “npm run build --prod”.