Install Cordova plugin without package.json file on it

删除回忆录丶 提交于 2019-12-01 17:37:45

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

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.

--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 cordova@7.1.0

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 cordova@7.1.0

Then, check the Cordova version:

cordova --version
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!