I just cloned repository of the cordova app, but in .gitignore file added dir /plugins.
How can i install these missing plugins? U tried to find any config file where used plugins are saved, but without luck.
Many thanks for any advice.
You can use ionic state to manage plugins and plateforms.
https://github.com/driftyco/ionic-cli#ionic-state
Read package.json and install listed plugins / plateforms :
ionic state restore
Save current plugins / platforms to the package.json :
ionic state save
Remove everything ! (including the default Ionic plugins ...) :
ionic state clear
Remove everything and bring back what you have specified in your package.json :
ionic state reset
cordova prepare seemed to do the trick for me. After cloning my repository I was getting a "No platforms added to this project" error when running cordova requirements, even though the platforms were listed in the config.xml. Running cordova prepare filled out the plugins directories, allowingcordova requirements to run.
If you added the add_plugin & remove plugin hooks, your package.json shall have a cordovaPlugins list.
If yes, then, the solution that i used is to remove the platform and add it again to fetch for all plugins
cordova platform remove android
cordova platform add android
here are the needed hooks
hooks/after_plugin_add/010_register_plugin.js
#!/usr/bin/env node
/**
* Push plugins to cordovaPlugins array after_plugin_add
*/
var fs = require('fs');
var packageJSON = require('../../package.json');
packageJSON.cordovaPlugins = packageJSON.cordovaPlugins || [];
process.env.CORDOVA_PLUGINS.split(',').forEach(function (plugin) {
if(packageJSON.cordovaPlugins.indexOf(plugin) == -1) {
packageJSON.cordovaPlugins.push(plugin);
}
});
fs.writeFileSync('package.json', JSON.stringify(packageJSON, null, 2));
hooks/after_plugin_rm/010_deregister_plugin.js
#!/usr/bin/env node
/**
* Remove plugins from cordovaPlugins array after_plugin_rm
*/
var fs = require('fs');
var packageJSON = require('../../package.json');
packageJSON.cordovaPlugins = packageJSON.cordovaPlugins || [];
process.env.CORDOVA_PLUGINS.split(',').forEach(function (plugin) {
var index = packageJSON.cordovaPlugins.indexOf(plugin);
if (index > -1) {
packageJSON.cordovaPlugins.splice(index, 1);
}
});
fs.writeFile('package.json', JSON.stringify(packageJSON, null, 2));
hooks/after_platform_add/010_install_plugins.js
#!/usr/bin/env node
/**
* Install all plugins listed in package.json
* https://raw.githubusercontent.com/diegonetto/generator-ionic/master/templates/hooks/after_platform_add/install_plugins.js
*/
var exec = require('child_process').exec;
var path = require('path');
var sys = require('sys');
var packageJSON = require('../../package.json');
var cmd = process.platform === 'win32' ? 'cordova.cmd' : 'cordova';
// var script = path.resolve(__dirname, '../../node_modules/cordova/bin', cmd);
packageJSON.cordovaPlugins = packageJSON.cordovaPlugins || [];
packageJSON.cordovaPlugins.forEach(function (plugin) {
exec('cordova plugin add ' + plugin, function (error, stdout, stderr) {
sys.puts(stdout);
});
});
One other solution is to add a task for plugin installation as described on this page : http://jbavari.github.io/blog/2014/06/24/managing-cordova-plugins-with-package-dot-json-and-hooks/
You can use
ionic cordova prepare <platform>
It will give you the list of plugins that are not installed with error message.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With