we are developing a couple of NPM packages under the same organization:
@aerogearservices/core
@aerogearservices/core-rn
@aerogearservices/core-cordova
Where core-cordova
is a Cordova plugin, installed via dependencies (read more about scoped packages).
Relevant files:
App's package.json
{
...
"dependencies": {
"@aerogearservices/core-cordova": "1.0.0",
...
},
"cordova": {
"plugins": {},
"platforms": ["ios", "android"]
}
}
Plugin's package.json
{
"name": "@aerogearservices/core-cordova",
"version": "1.0.0",
...
"cordova": {
"id": "aerogearservices-core-cordova",
"platforms": [
"android"
]
},
"dependencies": {
"@aerogearservices/core": "1.0.0"
},
"engines": {
"cordovaDependencies": {
...
}
}
}
Plugin's plugin.xml
... ... Apache 2.0
<platform name="android">
<config-file target="res/xml/config.xml" parent="/*">
...
</config-file>
<source-file
...
/>
</platform>
The plugin really does nothing yet, I am just trying to install it in my app but when I run cordova platform add android
I get this error:
UnhandledPromiseRejectionWarning: CordovaError: Cannot find plugin.xml for plugin "@aerogearservices". Please try adding it again.
The problem is that Cordova installs the plugin under myApp/plugins/aerogearservices/core-cordova
so that it is looking for plugin.xml
at the wrong location.
How do scoped packages and cordova plugins work together? Is there any workaround to this without renaming the plugin?
It might not be the slution to your problem, but I ended up having problems creating a cordova plugin published in a scoped npm registry, and this is how I managed to fix it:
Plugin's config.xml should not mention the scope:
<plugin id="cordova-plugin-myplugin" ...>
<name>cordova-plugin-myplugin</name>
On the other hand, plugin's package.json should mention it:
"name": "@scope/cordova-plugin-myplugin",
"cordova": {
"id": "@scope/cordova-plugin-myplugin",
"platforms": [
"android",
"windows",
"ios"
]
},
now, I have no problem using
cordova plugin add @scope/cordova-plugin-myplugin
I hope this might actually help someone
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