I am developing a cordova plugin that has dependencies to other plugins. I am not able to install the plugin without passing the --fetch parameter.
Here's how my plugin dependencies look like in the original plugin's xml file:
<dependency url="https://bitbucket.org/MY_REPO_URL" id="SOME_PLUGIN_ID"/>
<dependency url="https://bitbucket.org/MY_REPO_URL" id="SOME_OTHER_PLUGIN_ID" subdir="SOME_SUBDIR"/>
When I try to install the original plugin without using --nofetch:
cordova plugin add ORIGINAL_PLUGIN_ID
I get the following error:
No scripts found for hook "before_plugin_add".
No version specified for SOME_PLUGIN_NAME, retrieving version from package.json
Calling plugman.fetch on plugin "SOME_PLUGIN_NAME@^2.4.3"
saving
Running command: npm install SOME_PLUGIN_NAME@^2.4.3 --production --save
Command finished with error code 0: npm install,SOME_PLUGIN_NAME@^2.4.3,--production,--save
Copying plugin ".../test/node_modules/ORIGINAL_PLUGIN_ID" => ".../test/plugins/ORIGIAL_PLUGIN_ID"
Calling plugman.install on plugin ".../test/plugins/ORIGINAL_PLUGIN_ID" for platform "android
Installing "ORIGINAL_PLUGIN_ID" for android
Running command: .../test/platforms/android/cordova/version
Command finished with error code 0: .../test/platforms/android/cordova/version
Dependencies detected, iterating through them...
Requesting plugin "SOME_PLUGIN_ID".
Plugin dependency "SOME_PLUGIN_ID" not fetched, retrieving then installing.
saving
Running command: npm install https://bitbucket.org/MY_REPO_URL --production --save
Command finished with error code 0: npm install,https://bitbucket.org/MY_REPO_URL,--production,--save
Failed to install 'ORIGINAL_PLUGIN_ID': Error
at /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/fetch.js:215:37
at _rejected (/usr/local/lib/node_modules/cordova/node_modules/cordova-fetch/node_modules/q/q.js:864:24)
at /usr/local/lib/node_modules/cordova/node_modules/cordova-fetch/node_modules/q/q.js:890:30
at Promise.when (/usr/local/lib/node_modules/cordova/node_modules/cordova-fetch/node_modules/q/q.js:1142:31)
at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/cordova/node_modules/cordova-fetch/node_modules/q/q.js:808:41)
at /usr/local/lib/node_modules/cordova/node_modules/cordova-fetch/node_modules/q/q.js:624:44
at runSingle (/usr/local/lib/node_modules/cordova/node_modules/cordova-fetch/node_modules/q/q.js:137:13)
at flush (/usr/local/lib/node_modules/cordova/node_modules/cordova-fetch/node_modules/q/q.js:125:13)
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9)
Error: Failed to fetch plugin https://bitbucket.org/MY_REPO_URL via registry.
Probably this is either a connection problem, or plugin spec is incorrect.
Check your connection and plugin name/version/URL.
TypeError: Parameter "url" must be a string, not undefined
If I use --nofetch, the installation works perfectly.
cordova plugin add ORIGINAL_PLUGIN_NAME --nofetch
I'd like to know if there is anything I can do so that I can add the plugin without using --nofetch
We solved this by publishing the dependencies in npm and removing the subdir and url attributes (just adding the plugin id).
Now we can add the plugins without --nofetch to a project.
I also found out that the subdir feature is being deprecated internally in cordova as npm becomes the default option. Unfortunately, this is not documented and the subdir option for dependencies is still documented as a supported and non-deprecated feature.