I have a series of plugins that are not published in the npm registry and for various reasons, they will never be. These exist as GitHub repos.
Given that cordova 8 (actually starting 7.1.0) has removed nofetch
how do we specify cordova plugins in config.xml
(or package.json
) that install these plugins when the user does a cordova prepare
?
Example: This is in package.json (as well as config.xml)
<plugin name="org.devgeeks.Canvas2ImagePlugin" spec="https://github.com/devgeeks/Canvas2ImagePlugin.git">
When you do cordova prepare
Discovered plugin "org.devgeeks.Canvas2ImagePlugin" in config.xml. Adding it to the project
Failed to restore plugin "org.devgeeks.Canvas2ImagePlugin" from config.xml. You might need to try adding it again. Error: Failed to fetch plugin https://github.com/devgeeks/Canvas2ImagePlugin via registry.
Probably this is either a connection problem, or plugin spec is incorrect.
Check your connection and plugin name/version/URL.
Failed to get absolute path to installed module
However manually doing the same thing works just fine:
cordova plugin add https://github.com/devgeeks/Canvas2ImagePlugin.git
Installing "org.devgeeks.Canvas2ImagePlugin" for android
Installing "org.devgeeks.Canvas2ImagePlugin" for ios
Adding org.devgeeks.Canvas2ImagePlugin to package.json
Saved plugin info for "org.devgeeks.Canvas2ImagePlugin" to config.xml
This particular plugin does not have an npm registry. The same holds true for any other plugin that doesn't have an npm registry.
First, you have to pass the plugin-spec command in the command prompt. Then, plugin-spec is saved into the xml and package. json file of an app. After saving the file, we can publish the latest plugin version to npm that our current project supports.
(Not marking this as an answer, because I did the opposite of what I wanted to do)
I gave up trying to do this. It was much simpler to publish my changes to the npm registry with a different ID. I personally think this is a terrible mechanism - I consider the npm registry as a 'good list of plugins' and really shouldn't be littered with modifications that don't add a global value, but I found no option.
So I:
originalplugin-myid-fork
package.json
and config.xml
to just refer to these ids as they are now on npm registry (I like them both to be in sync)Backstory (for context and what I tried):
My criteria was to make it easy for my users to install my software simply by doing npm install && bower install && cordova prepare
npm install
would create the plugin shims inside node_modules
which had the same ids as the original plugins. config.xml
and package.json
had a spec="my fork url"
, for whatever reason, cordova prepare
would go looking for that id in the npm registry and start complaining. npm install
a manual install of cordova plugin add https://mygit.git
would fail with the same error. The only way to make this manual command work again was to remove that plugin's definition from node_modules
. --no-registry
option - could never get it working - kept complaining about missing local paths.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With