I am wondering is there an easier way to update cordova plugin?
I googled, found a hook (@ year 2013), but this is not 100% what I want.
I know I can do this
npm update -f
its working form me
npm update -f
it will update all plugins and cli
You don't need remove, just add again.
cordova plugin add https://github.com/apache/cordova-plugin-camera
you cannot update ,but i wrote a batch file that removes my plugins and install again so in this case my all plugins are updated automatically, hope this solves your problem
@echo off
for %%a in (
"com.ionic.keyboard"
"com.phonegap.plugins.PushPlugin"
"cordova-instagram-plugin"
"cordova-plugin-camera"
"cordova-plugin-crosswalk-webview"
"cordova-plugin-file"
"cordova-plugin-file-transfer"
) do call cordova plugin rm %%a
for %%b in (
"com.ionic.keyboard"
"com.phonegap.plugins.PushPlugin"
"cordova-instagram-plugin"
"cordova-plugin-camera"
"cordova-plugin-crosswalk-webview"
"cordova-plugin-file"
"cordova-plugin-file-transfer"
) do call cordova plugin add %%b
If you install the third party package:
npm i cordova-check-plugins
You can then run a simple command of
cordova-check-plugins --update=auto --force
Keep in mind forcing anything always comes with potential risks of breaking changes.
As other answers have stated, the connecting NPM packages that manage these plugins also require a consequent update when updating the plugins, so now you can check them with:
npm outdated
And then sweeping update them with
npm update
Now tentatively serve your app again and check all of the things that have potentially gone awry from breaking changes. The joy of software development! :)
This is my Windows Batch version for update all plugins in one command
How to use:
From command line, in the same folder of project, run
c:\> batchNameFile
or
c:\> batchNameFile autoupdate
Where "batchNameFile" is the name of .BAT file, with the script below.
For only test ( first exmple ) or to force every update avaiable ( 2nd example )
@echo off
cls
set pluginListFile=update.plugin.list
if exist %pluginListFile% del %pluginListFile%
Echo "Reading installed Plugins"
Call cordova plugins > %pluginListFile%
echo.
for /F "tokens=1,2 delims= " %%a in ( %pluginListFile% ) do (
Echo "Checking online version for %%a"
for /F "delims=" %%I in ( 'npm info %%a version' ) do (
Echo "Local : %%b"
Echo "Online: %%I"
if %%b LSS %%I Call :toUpdate %%a %~1
:cont
echo.
)
)
if exist %pluginListFile% del %pluginListFile%
Exit /B
:toUpdate
Echo "Need Update !"
if '%~2' == 'autoupdate' Call :DoUpdate %~1
goto cont
:DoUpdate
Echo "Removing Plugin"
Call cordova plugin rm %~1
Echo "Adding Plugin"
Call cordova plugin add %~1
goto cont
This batch was only tested in Windows 10
Go to your cordova
project directory then write
npm outdated
npm
will be display your outdated plugins
, if any plugin outdated
then write this command
npm update