Cannot find module “ionic-native”

后端 未结 3 1238
走了就别回头了
走了就别回头了 2020-12-16 14:01

I tried

npm install ionic-native --save

npm install @ionic-native/core --save both command still give Runtime error

Ca         


        
相关标签:
3条回答
  • 2020-12-16 14:41

    The package ionic-native doesn't exist anymore. The modules are now in its own package:

    import { StatusBar } from '@ionic-native/status-bar';
    import { SplashScreen } from '@ionic-native/splash-screen';
    
    0 讨论(0)
  • 2020-12-16 14:50
    import { StatusBar } from '@ionic-native/status-bar/ngx';
    import { SplashScreen } from '@ionic-native/splash-screen/ngx';
    
    0 讨论(0)
  • 2020-12-16 15:00

    You need to remove "ionic-native": "^3.5.0" from your package.json and after that run npm i.

    You need to use all your native plugins as providers as shown below.

    app.component.ts

     import { StatusBar } from '@ionic-native/status-bar';
     import { SplashScreen } from '@ionic-native/splash-screen';
    
    constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen) {
            platform.ready().then(() => {
                statusBar.styleDefault();
                splashScreen.hide();
            });
        }
    

    app.module.ts

    import { SplashScreen } from '@ionic-native/splash-screen';
    import { StatusBar } from '@ionic-native/status-bar';
    
    @NgModule({
    providers: [
        StatusBar,
        SplashScreen,
       ]
    })
    export class AppModule { }
    

    You can read more about this new implementation on official doc here.

    0 讨论(0)
提交回复
热议问题