Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install Cordova plugin without package.json file on it

I'm trying to install a Cordova Plugin with Cordova CLI 7.

This plugin does not have a package.json file on it, so it throws an error when adding it to my project.

I've tried converting the config.xml file using plugman. And it works fine for Android but it doesn't for iOS. I feel like I'm missing some configuration from the config.xml in my package.json file.

Is there a way to safely convert the config.xml in a package.json file? or a way to install it using the config.xml file?

Thanks

like image 432
Victor Avatar asked Jul 01 '17 12:07

Victor


People also ask

How do I add a plugin to config xml cordova?

When adding plugins or platforms, use the --save flag to add them to config. xml. Ex: cordova platform add android --save. Existing projects can use cordova plugin save and cordova platform save commands to save all previously installed plugins and platforms into your project's config.


3 Answers

For me when adding a custom plugin like so

cordova plugin add .\custom-plugins\my-plugin --nofetch

This does not work on MAC for me for some reason.

I resort to building it all for Android then copy over all the files, except node_modules and platforms, then do a 'cordova build ios' it seems to build fine with the custom plugins included. Not the best way i know, but once the plugin is added i can move on and continue. If you get it to work please share.

like image 45
dale Avatar answered Sep 28 '22 19:09

dale


Yes, since Cordova 7, the installation of platforms and plugins are by default performed using cordova-fetch which in turn uses npm install to add/remove modules. Therefore a package.json is required by default. But you should be able to add plugins lacking a package.json file by using the nofetch parameter, which forces Cordova to use the old method instead, please note that this parameter has been removed in cordova 8.0.0:

cordova plugin add cordova-plugin-camera --nofetch

like image 60
Edin Avatar answered Sep 28 '22 19:09

Edin


--nofetch option is removed in Cordova 8.0.0: https://issues.apache.org/jira/browse/CB-13055

If you have already installed Cordova 8.x.x then you can downgrade it to version 7.1.0 and then use the --nofetch option.

Run the following command to downgrade Cordova to 7.1.0:

npm install -g [email protected]

If the above command doesn't work, then try uninstalling cordova at first and then install cordova version 7.1.0:

npm uninstall -g cordova
npm install -g [email protected]

Then, check the Cordova version:

cordova --version
like image 21
Mukesh Chapagain Avatar answered Sep 28 '22 17:09

Mukesh Chapagain