Victor
Victor

Reputation: 206

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

Upvotes: 6

Views: 8473

Answers (3)

Edin
Edin

Reputation: 356

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

Upvotes: 8

Mukesh Chapagain
Mukesh Chapagain

Reputation: 25968

--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

Upvotes: 2

dale
dale

Reputation: 1258

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.

Upvotes: 2

Related Questions