ionic-team / ionic-framework

A powerful cross-platform UI toolkit for building native-quality iOS, Android, and Progressive Web Apps with HTML, CSS, and JavaScript.
https://ionicframework.com
MIT License
51.07k stars 13.51k forks source link

Cannot find module "ionic-native" #11091

Closed jcmartins closed 7 years ago

jcmartins commented 7 years ago

Ionic version: (check one with "x") [ ] 1.x [] 2.x [x]3.x

I'm submitting a ... (check one with "x") [x ] bug report [ ] feature request [ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or http://ionicworldwide.herokuapp.com/

Current behavior:

upgrade to version 3 Expected behavior:

Error: Cannot find module "ionic-native" at g (http://localhost:8100/build/polyfills.js:3:7133) at Object. (http://localhost:8100/build/main.js:107109:7) at webpack_require (http://localhost:8100/build/main.js:20:30) at Object. (http://localhost:8100/build/main.js:80974:73) at webpack_require (http://localhost:8100/build/main.js:20:30) at Object. (http://localhost:8100/build/main.js:119490:70) at __webpack_require__ (http://localhost:8100/build/main.js:20:30) at http://localhost:8100/build/main.js:66:18 at http://localhost:8100/build/main.js:69:10

Steps to reproduce:

Related code:

{
  "name": "my-app",
  "author": "jc",
  "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.0",
    "ionicons": "3.0.0",
    "rxjs": "5.1.1",
    "sw-toolbox": "3.4.0",
    "zone.js": "^0.8.4"
  },
  "devDependencies": {
    "@ionic/app-scripts": "1.3.0",
    "typescript": "~2.2.1"
  }
}

ls -la node_modules/@ionic-native:
total 36
drwxr-xr-x   5 jc jc  4096 abr  6 11:15 .
drwxr-xr-x 504 jc jc 20480 abr  6 11:15 ..
drwxr-xr-x   2 jc jc  4096 abr  6 11:15 core
drwxr-xr-x   2 jc jc  4096 abr  6 11:15 splash-screen
drwxr-xr-x   2 jc jc  4096 abr  6 11:15 status-bar

Other information:

Ionic info: (run ionic info from a terminal/cmd prompt and paste output below):

Ionic Framework: 3.0.0
Ionic App Scripts: 1.3.0
Angular Core: 4.0.0
Angular Compiler CLI: 4.0.0
Node: 7.7.3
OS Platform: Linux 4.10
Navigator Platform: Linux x86_64
User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36
dlemphers commented 7 years ago

Because Ionic3 upgraded to Ionic-Native 3.x you'll need to update your imports where you're using ionic-native.

All the doco is updated, which is what I used to update where I'm using stuff like SplashScreen, StatusBar, and Device.

miguelcarrascoq commented 7 years ago

I have the same issue. http://imgur.com/a/ei35J My ionic info:

Cordova CLI: 6.5.0 Ionic Framework Version: 3.0.0 Ionic CLI Version: 2.2.1 Ionic App Lib Version: 2.2.0 Ionic App Scripts Version: 1.3.0 ios-deploy version: 1.9.1 ios-sim version: 5.0.13 OS: macOS Sierra Node Version: v7.5.0 Xcode version: Xcode 8.3 Build version 8E162

miguelcarrascoq commented 7 years ago

Sorry guys. It was my fault. I was using: import { InAppBrowser } from 'ionic-native'; instead of: import { InAppBrowser } from '@ionic-native/in-app-browser';

Now everything works again

wbhob commented 7 years ago

Yes, when you remove the ionic-native dependency from package.json, you remove the package so you have to remove it from your code.

brandyscarney commented 7 years ago

Please take a look at the following blog for updating to Ionic Native 3.x: http://blog.ionic.io/ionic-native-3-x/

See step 4 of the steps to upgrade: https://github.com/driftyco/ionic/blob/master/CHANGELOG.md#steps-to-upgrade

And an example commit that shows the changes: https://github.com/driftyco/ionic-conference-app/commit/62088

If you are having issues with Ionic Native after this please open a new issue here: https://github.com/driftyco/ionic-native/issues

Thank you! 😄

Sherbadshah commented 7 years ago

I want to work in all versions like ionic 1, 2 and 3. So what's the solution ?

wbhob commented 7 years ago

Use Ionic native 2.x for Ionic 1, and Ionic native 3.x for ionic 2+ http://blog.ionic.io/ionic-native-3-x/

@Sherbadshah

SVANNER commented 7 years ago

Hi, I have the same kind of problem with the new Ionic 3 framework hetting SQLite:

import { SQLite } from 'ionic-native'

I get the error " cannot find module 'ionic-native'"

What can i do to get the SQLite class with Ionic 3 ?

Thanks a lot !

wbhob commented 7 years ago

The module is @ionic-native/sqlite

Wilson Hobbs CEO/Founder/Developer at Canal 11th Grade at The Lovett School

Personal Information E-mail: wilsonhobbs1@gmail.com Cell: (404) 719-3252 Website: www.wilsonhobbs.com (https://www.wilsonhobbs.com) Twitter/Instagram/Facebook: @wbhob

Canal Information E-mail: wilson@getcanal.com Web: www.getcanal.com (https://www.getcanal.com/)

Twitter/Instagram/Facebook: @getcanal

On Apr 17, 2017, 3:43 PM -0400, SVANNER notifications@github.com, wrote:

Hi, I have the same kind of problem with the new Ionic 3 framework hetting SQLite:

import { SQLite } from 'ionic-native'

I get the error " cannot find module 'ionic-native'"

What can i do to get the SQLite class with Ionic 3 ?

Thanks a lot !

— You are receiving this because you commented. Reply to this email directly, view it on GitHub (https://github.com/driftyco/ionic/issues/11091#issuecomment-294569825), or mute the thread (https://github.com/notifications/unsubscribe-auth/AEPIEjyHEIQBaHMA8MPmSU5FyqthqcEAks5rw8DggaJpZM4M1sIL).

SVANNER commented 7 years ago

Thanks a lot ! It Workshop !

gopi2mohan commented 7 years ago

i am still facing this issue where i have commented all the plugin related code in my pages and inside my app.module.ts file i have imported and added all the plugins inside my providers array also but still i am facing this issue check this http://stackoverflow.com/questions/43759991/ionic-3-type-any-is-not-a-constructor-function-type/43760070?noredirect=1#comment74561931_43760070 where i have placed a question and details about my project

payen83 commented 7 years ago

I found my solution. You need to change at app.component.ts

Remove this: import { StatusBar, Splashscreen } from 'ionic-native';

..and add this: import { StatusBar } from '@ionic-native/status-bar'; import { SplashScreen } from '@ionic-native/splash-screen';

If you recently removed the node_modules, please reinstall those native plugins again at terminal/cmd:

$ npm install --save @ionic-native/status-bar 
$ npm install --save @ionic-native/splash-screen
$ npm install --save @ionic-native/core 
wmehanna commented 7 years ago

@payen83 thanks for this.

ionitron-bot[bot] commented 6 years ago

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.