简体   繁体   English

如何在没有此错误的情况下安装分叉和定制的离子原生cordova插件?

[英]How to install a forked and customized ionic native cordova plugin without this error?

I am trying to fork a cordova plugin, apply some modifications, and then install it into my Ionic 4 project.我正在尝试 fork 一个 cordova 插件,应用一些修改,然后将它安装到我的 Ionic 4 项目中。

I did the following:我做了以下事情:

Step 1: I forked the plugin to my own Github repo第 1 步:我将插件分叉到我自己的 Github 存储库

Step 2: I added this plugin successfully to my project using the command: ionic cordova plugin add https://github.com/[MYUSERNAME]/cordova-plugin-speechrecognition --save .第 2 步:我使用以下命令将此插件成功添加到我的项目中: ionic cordova plugin add https://github.com/[MYUSERNAME]/cordova-plugin-speechrecognition --save

I can verify that this step went well as my changes are reflected in the plugins folder and in package.json I observe the link to my repo:我可以验证这一步是否顺利,因为我的更改反映在plugins文件夹和package.json我观察到我的 repo 的链接:

"cordova-plugin-speechrecognition": "git+https://github.com/[MYUSERNAME]/cordova-plugin-speechrecognition.git" . "cordova-plugin-speechrecognition": "git+https://github.com/[MYUSERNAME]/cordova-plugin-speechrecognition.git"

Step 3: Then it goes wrong when I try to install this plugin.第 3 步:然后当我尝试安装此插件时出错。 When I run the command npm install @ionic-native/speech-recognition I get the error:当我运行命令npm install @ionic-native/speech-recognition ,出现错误:

$ npm install @ionic-native/speech-recognition --save npm WARN ajv-keywords@3.4.0 requires a peer of ajv@^6.9.1 but none is installed. $ npm install @ionic-native/speech-recognition --save npm WARN ajv-keywords@3.4.0 需要 ajv@^6.9.1 的对等点,但没有安装。 You must install peer dependencies yourself.您必须自己安装对等依赖项。 npm WARN ionic-image-loader@7.0.0-beta.2 requires a peer of @ionic-native/file@^5.0.0-beta.21 but none is installed. npm WARN ionic-image-loader@7.0.0-beta.2 需要@ionic-native/file@^5.0.0-beta.21 的同级,但没有安装。 You must install peer dependencies yourself.您必须自己安装对等依赖项。 npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.8 (node_modules\\fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.8: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"}) npm WARN 可选跳过可选依赖:fsevents@1.2.8 (node_modules\\fsevents):npm WARN notsup 跳过可选依赖:fsevents@1.2.8 不支持平台:想要 {"os":"darwin","arch": "} (当前: {"os":"win32","arch":"x64"})

  • @ionic-native/speech-recognition@5.5.0 updated 1 package and audited 53115 packages in 14.827s @ionic-native/speech-recognition@5.5.0 在 14.827 秒内更新了 1 个包并审核了 53115 个包

found 2 vulnerabilities (1 low, 1 high) run npm audit fix to fix them, or npm audit for details发现 2 个漏洞(1 低,1 高)运行npm audit fix来修复它们,或npm audit了解详细信息

What did I do wrong here and what this error even mean?我在这里做错了什么,这个错误甚至意味着什么?

@ionic-native plugins work in a different way than other Cordova plugins. @ionic-native 插件的工作方式与其他 Cordova 插件不同。

They publish the plugin wrappers with npm scripts under their respective URLs.他们在各自的 URL 下发布带有 npm 脚本的插件包装器。 In other words, each plugin wrapper has a corresponding npm package but not a separate Git repo, so you can't refer to to individual wrappers via Github URLs directly (in your package.json file).换句话说,每个插件包装器都有一个对应的 npm 包,但没有一个单独的 Git 存储库,所以你不能直接通过 Github URL 引用单个包装器(在你的 package.json 文件中)。

Possible workarounds are:可能的解决方法是:

  1. Copy @ionic-native plugin package locally, make changes, add to your Git repo, and install your modified npm package locally with npm install /path/to/your/folder在本地复制 @ionic-native 插件包,进行更改,添加到您的 Git 存储库,并使用 npm install /path/to/your/folder 在本地安装修改后的 npm 包
  2. Fork the plugin on Github, make changes (optionally: submit a Pull request), publish the modified plugin as a separate npm package在 Github 上 fork 插件,进行更改(可选:提交 Pull 请求),将修改后的插件作为单独的 npm 包发布

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM