Ionic 4发行后,Ionic 3错误安装本机插件

时间:2019-01-25 08:18:46

标签: ionic-framework cordova-plugins

当成功安装Native Store时,使用本地插件ionic 3会出现问题,但是当我尝试在应用模块中添加时,文本编辑器显示红线,而当我尝试运行时,发现了如下错误。我在这里安装本机存储(https://ionicframework.com/docs/v3/native/native-storage/

文本编辑器中的红线,安装成功,但是在应用模块中添加时显示红线。 enter image description here

enter image description here

当运行“ 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

请帮助我解决这个问题。

谢谢。

4 个答案:

答案 0 :(得分:4)

尝试查找..倒数第二个上一个版本,并在添加插件时附加

npm install @ionic-native/native-storage@4.19.0

此处...最新版本为5.0.0,因此请添加@ 4.19.0,请不要基于此进行假设
Number Go In Repo或npm链接尝试找到我们的先前版本,然后附加。

然后定期执行所有步骤。

谢谢

答案 1 :(得分:1)

现在,您的所有@ionic-native模块最终都需要/ngx用于Angular项目。像这样修复它:

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

将此应用于每个@ionic-native插件/模块。

答案 2 :(得分:0)

转到https://www.npmjs.com

搜索要安装的离子本机软件包。

在您的情况下,其为“离子型本机存储”。 检查版本并选择在Ionic 4 Beta发行之前发布的版本,然后使用相同的命令安装适当的版本。

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

此后,该插件将以与以前相同的方式工作。 无需在路径末尾添加“ ngx”。

答案 3 :(得分:-1)

对于那些在Ionic 5上运行的用户,只需从以下位置修复导入语句即可:

从“ @ ionic-native / barcode-scanner”导入{BarcodeScanner};

收件人:

从“ @ ionic-native / barcode-scanner / ngx”导入{BarcodeScanner};

否则,上面的工作适用于Ionic 3.9x和Ionic 4.xx