Ionic 3 error install native plugin after Ionic 4 release
Asked Answered
O

4

5

I get a problem using native plugin ionic 3 when install Native Store is success, but when I try to add in app module, the text editor show a red line and when I try to run I found an error like below. Here I install Native-store (https://ionicframework.com/docs/v3/native/native-storage/)

Red line in text editor, successful install but when add in app module show red line. enter image description here

enter image description here

This is error in console when run 'ionic cordova run android'.

[14:40:05]  ionic-app-scripts 3.1.8
[14:40:05]  build dev started ...
[14:40:05]  clean started ...
[14:40:05]  clean finished in 71 ms
[14:40:05]  copy started ...
[14:40:07]  deeplinks started ...
[14:40:08]  deeplinks finished in 1.04 s
[14:40:08]  transpile started ...
[14:40:27]  typescript: D:/myProject/ionic/myApp/src/app/app.module.ts, line: 57
            Argument of type '{ declarations: (typeof VerificationPage | typeof LoginPage | typeof PrivacyRegisterPage |
            typeof...' is not assignable to parameter of type 'NgModule'. Types of property 'providers' are
            incompatible. Type '(typeof SplashScreen | typeof FCM | typeof InAppBrowser | typeof AppVersion | typeof
            Market | typ...' is not assignable to type 'Provider[]'. Type 'typeof SplashScreen | typeof FCM | typeof
            InAppBrowser | typeof AppVersion | typeof Market | type...' is not assignable to type 'Provider'. Type
            'NativeStorageOriginal' is not assignable to type 'Provider'. Type 'NativeStorageOriginal' is not assignable
            to type 'ClassProvider'. Property 'provide' is missing in type 'NativeStorageOriginal'.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
[14:40:27]  ionic-app-script task: "build"
[14:40:27]  Error: Failed to transpile program
Error: Failed to transpile program
    at new BuildError (D:\myProject\ionic\myApp\node_modules\@ionic\app-scripts\dist\util\errors.js:16:28)
    at D:\myProject\ionic\myApp\node_modules\@ionic\app-scripts\dist\transpile.js:159:20
    at Promise (<anonymous>)
    at transpileWorker (D:\myProject\ionic\myApp\node_modules\@ionic\app-scripts\dist\transpile.js:107:12)
    at Object.transpile (D:\myProject\ionic\myApp\node_modules\@ionic\app-scripts\dist\transpile.js:64:12)
    at D:\myProject\ionic\myApp\node_modules\@ionic\app-scripts\dist\build.js:109:82
    at <anonymous>
[ERROR] Command not found: ionic-app-scripts

Please help me to solve this problem.

Thanks.

Oeflein answered 25/1, 2019 at 8:18 Comment(4)
You have to use import { DocumentViewer} from "@ionic-native/document-viewer/ngx"; like this.Pavement
No, What do you install DocumentViewer for ?, I try to install NativeStorage, not DocumentViewer. Do you have another idea/solution ? @MustafaLokhandwalaOeflein
at last you have a problem to import the module in app.module.ts right?Pavement
ya, right, I try to import in another ionic 3 project the result is same, error. One day before I install its ok, but after ionic 4 release to be error. @MustafaLokhandwalaOeflein
U
6

Try To Find .. Second Last Previous Version of Plugin & Append While Adding Plugin

npm install @ionic-native/[email protected]

Here... Latest Version is 5.0.0 So Add @4.19.0 Please Don't Make Assumption Based On
Number Go In Repo or npm link try to find our previous version then append.

Then do your All Step Regularly.

Thanks

Unthankful answered 25/1, 2019 at 12:8 Comment(3)
This is the solution. It made me mad, 'cause it's about 2 hours I try to install any pulgin unsuccessfully.Nigger
@Krunal Vaghela, Do you know where can I check the lastest version. . ?lika a list of versionOeflein
You Can Check in npm.. tell me For Which Plugin You Are Trying ?Unthankful
R
13

All your @ionic-native modules now need /ngx at the end for Angular projects. Just fix it like this:

import { NativeStorage } from '@ionic-native/native-storage/ngx';

Apply this to every @ionic-native plugin/module.

Rupe answered 25/1, 2019 at 19:46 Comment(0)
U
6

Try To Find .. Second Last Previous Version of Plugin & Append While Adding Plugin

npm install @ionic-native/[email protected]

Here... Latest Version is 5.0.0 So Add @4.19.0 Please Don't Make Assumption Based On
Number Go In Repo or npm link try to find our previous version then append.

Then do your All Step Regularly.

Thanks

Unthankful answered 25/1, 2019 at 12:8 Comment(3)
This is the solution. It made me mad, 'cause it's about 2 hours I try to install any pulgin unsuccessfully.Nigger
@Krunal Vaghela, Do you know where can I check the lastest version. . ?lika a list of versionOeflein
You Can Check in npm.. tell me For Which Plugin You Are Trying ?Unthankful
S
0

Goto https://www.npmjs.com.

Search for the ionic-native package that you want to install.

In your case, its 'ionic-native-storage'. Check the versions and choose the one which was released before the Ionic 4 Beta release and then install the appropriate version using the same command.

ionic cordova plugin add cordova-plugin-nativestorage@"====add your version here===="

After that the plugin will work the same way as it did. No need to fiddle with adding 'ngx' at the end of the path.

Stantonstanway answered 30/1, 2019 at 11:28 Comment(0)
F
-1

For those that end here running on Ionic 5 just fix your import statement from:

import { BarcodeScanner } from ‘@ionic-native/barcode-scanner’;

to:

import { BarcodeScanner } from ‘@ionic-native/barcode-scanner/ngx’;

Otherwise the above work for Ionic 3.9x and Ionic 4.xx

Floatation answered 13/7, 2020 at 10:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.