Reputation: 6126
I install cordova plugins using the below commands
npm install @ionic-native/xx --save
ionic cordova plugin add xx
Upvotes: 1
Views: 198
Reputation: 10237
First and Second Question
The npm install
command is used to install any package as dependency or dev dependency to your project. Once downloaded, the package would reside in your node_modules folder.
ionic cordova plugin add xx
on the other hand is to add a plugin to your cordova project. It uses npm to download the plugin, which is why you will see it in the node_modules
folder, then it will move files to the plugins
folder. Now, each time you build, the plugin file is copied from the plugins
folder to respective platform location.
For cordova/ionic projects, its a best practice to use the plugin add
command rather than use npm install
and add the plugin to the project manually.
Third Question
Creating a plugin for cordova is well documented in the cordova docs. It will guide you on how to build as well as publish a plugin for cordova.
Fourth Question
Cordova engine is a bridge which connects your code to the device mechanisms. Now, each platform sits on top of this engine which is why you need to add specific platforms for your use. This means, codova engine is same for ios and android, but the platforms vary, which is why you have two version.
cordova -v
will give you the engine version (latest is v9)
cordova platform ls
will give you your platform verion (android is v8, ios is v5)
Upvotes: 2