0

I am trying to fork a cordova plugin, apply some modifications, and then install it into my Ionic 4 project.

I did the following:

Step 1: I forked the plugin to my own Github repo

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.

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:

"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. When I run the command npm install @ionic-native/speech-recognition I get the error:

$ 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. 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. 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"})

  • @ionic-native/speech-recognition@5.5.0 updated 1 package and audited 53115 packages in 14.827s

found 2 vulnerabilities (1 low, 1 high) run npm audit fix to fix them, or npm audit for details

What did I do wrong here and what this error even mean?

WJA
  • 6,676
  • 16
  • 85
  • 152
  • 2
    I don't see any errors in your console output. I tend to ignore npm warnings like skipping optional dependecy, as they do not seem to do any harm. There are even Q&As here on StackOverflow on muting warning, eg. https://stackoverflow.com/q/27686889/5730444 – Phonolog Apr 22 '19 at 16:22
  • So this is the right way to do it? Changes should be reflected in the build? – WJA Apr 22 '19 at 16:27
  • Looks correct to me. Try it out :) You are aware that the `npm install @ionic-native/speech-recognition` will install the original plugin, not your modified/forked version? – Phonolog Apr 22 '19 at 16:31
  • No I am not? How would I then install this custom plugin with npm install? – WJA Apr 25 '19 at 08:02
  • 2
    See the [npm install docs](https://docs.npmjs.com/cli/install) or questions like [this one](https://stackoverflow.com/questions/17509669/how-to-install-an-npm-package-from-github-directly). You'll have to specify the link to **your** Github repo in the npm install command – Phonolog Apr 25 '19 at 08:26

1 Answers1

0

@ionic-native plugins work in a different way than other Cordova plugins.

They publish the plugin wrappers with npm scripts under their respective URLs. 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).

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
  2. Fork the plugin on Github, make changes (optionally: submit a Pull request), publish the modified plugin as a separate npm package
felipeclopes
  • 4,010
  • 2
  • 25
  • 35