Skip to content

bug: Remove --save from ionic cordova plugin add command #4027

Description

@bryplano

Description

When performing an ionic cordova plugin add plugin@~version, the range specifier for the version (in this case, the tilde (~) denoting patch versions are acceptable) is not applied due to the --save that is applied by the ionic version of the command.

Using cordova plugin add plugin@~version, the tilde is properly added to the plugin in package.json.

To ensure dependencies are being added properly with the right range specifier, we should remove --save from the Ionic version of this command.

Steps to Reproduce

Using the Ionic Command

In an Ionic project, run a command such as:

ionic cordova plugin add cordova-plugin-advanced-http@~2.0.0

The Ionic version of the command adds the --save flag. Upon installation, check package.json, where you will see:

"cordova-plugin-advanced-http": "2.0.11",

Notice there is no tilde ~ added to the version, restricting this to the explicit 2.0.11 version.

Now remove the plugin with ionic cordova plugin rm cordova-plugin-advanced-http.

Using the Cordova command

Next, run the Cordova version of the command:

cordova plugin add cordova-plugin-advanced-http@~2.0.0

Notice that the plugin added to package.json has the appropriate range specifier:

"cordova-plugin-advanced-http": "~2.0.11",

My ionic info

ionic info

Ionic:

   Ionic CLI                     : 5.0.2 (/usr/local/lib/node_modules/ionic)
   Ionic Framework               : @ionic/angular 4.4.2
   @angular-devkit/build-angular : 0.13.9
   @angular-devkit/schematics    : 7.3.9
   @angular/cli                  : 7.3.9
   @ionic/angular-toolkit        : 1.5.1

Cordova:

   Cordova CLI       : 9.0.3 (cordova-lib@9.0.2)
   Cordova Platforms : android 8.0.0
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 4.0.1, (and 7 other plugins)

Utility:

   cordova-res : not installed
   native-run  : 0.2.3

System:

   Android SDK Tools : 26.1.1 (/Users/bryantplano/Library/Android/sdk)
   ios-deploy        : 2.0.0
   ios-sim           : 8.0.1
   NodeJS            : v10.16.0 (/usr/local/bin/node)
   npm               : 6.9.0
   OS                : macOS Mojave
   Xcode             : Xcode 10.2.1 Build version 10E1001

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions