Closed Jule- closed 6 years ago
I have not investigating more but there is another side effect: if you have issues adding a plugin while the npm install
worked under the hood, next time you try to cordova prepare
you will have an error. The only way to get it work again is to remove the involved plugin folder in node_modules
and cordova prepare
again.
The problems you describe have already been resolved but the fixes have not yet been released. Take a look at the current code in the master
branch and feel free to test it using cordova@nightly
. The PR that fixed it is #18.
I'm closing this now, but if you feel this was in error, please feel free to say so.
@raphinesse oh great! I will try that and come back if issue still persists. Thanks for the info!
I ran into an issue which was hard to figured it out so I want to share it for others. Maybe something should be written somewhere in the documentation of
cordova-fetch
orcordova-cli
or even better this should be consolidated.My use case:
I develop a cordova plugin for my app in a bitbucket private repository and obviously I want to
cordova plugin add
it in my project.The issue:
First time I add my plugin on working project with the command:
All goes fine (nb: did not investigate why it goes fine on the first time). Problems happen when I was trying to start a fresh clone of my project.
As you can see
Command finished with error code 0: npm install
(OK) and thenFailed to restore plugin "cordova-plugin-my-plugin" from config.xml.
...Failed to get absolute path to installed module
🤔When I realized that, I started looking for code root issue:
cordova-cli
>cordova-lib
>cordova-fetch
And investigating independency-ls
, I understood howcordova-fetch
is checkingnpm install
execution success and how custom repository (out of registry) are handle as 'UNMET DEPENDENCY'.npm ls --depth=0
parsed bydependency-ls
under the hood)npm install
node_modules
5.1. try innode_modules/${package_id_issued_from_dependency_ls}
5.2. if failed try loading allnode_modules/*/package.json
and try to findgivenPackageUrl === pkg.repository.url
At start I thought my case matches 5.1. case... Wrong!
dependency-ls
in the particular case of out of registry packages output my package id has:UNMET DEPENDENCY cordova-plugin-my-plugin
... Then trying to findnode_modules/UNMET DEPENDENCY cordova-plugin-my-plugin/
... 🤪 So, go to 5.2.! And here I have made the most insidious mistake... In Bitbucket you can clone your repository with two differentand
And unfortunately I've added my plugin with one form while the other was in my
package.json
.Conclusion
While all is going well on the install,
cordova-fetch
wasn't able to realize it. And I really didn't expectcordova
relying on thepackage.json
repository url... I don't know why by designcordova-fetch
does not rely onnpm
exit code? And at least may be you should removeUNMET DEPENDENCY
from the package name in 5.1. so that directory exist test succeed.HTH, cheers!