Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-12816

Cordova platform add fails when using the npm that comes with cordova-lib



    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 7.0.0
    • Fix Version/s: 8.0.0
    • Component/s: cordova-lib
    • Labels:
    • Environment:

      Tested in Ubuntu 17.04 and OS X.


      When the npm version that is bundled with Cordova (2.15.12) is in PATH, adding Cordova platforms fails. The cause is that some npm packages are missing after cordova-android is installed.

      I tried to reproduce this, but I accidentally triggered a slightly different error message than intended.

      $ cordova create example
      Creating a new cordova project.
      $ cd example/
      $ npm init
      This utility will walk you through creating a package.json file.
      It only covers the most common items, and tries to guess sensible defaults.
      See `npm help json` for definitive documentation on these fields
      and exactly what they do.
      Use `npm install <pkg> --save` afterwards to install a package and
      save it as a dependency in the package.json file.
      Press ^C at any time to quit.
      name: (helloworld) 
      version: (1.0.0) 
      git repository: 
      license: (Apache-2.0) 
      About to write to /tmp/example/package.json:
        "name": "helloworld",
        "displayName": "HelloCordova",
        "version": "1.0.0",
        "description": "A sample Apache Cordova application that responds to the deviceready event.",
        "main": "index.js",
        "scripts": {
          "test": "echo \"Error: no test specified\" && exit 1"
        "author": "Apache Cordova Team",
        "license": "Apache-2.0"
      Is this ok? (yes)
      $ npm install cordova
      ... [TRUNCATED] ...
      $ PATH="$(npm bin):$PATH" cordova platform add android
      Using cordova-fetch for cordova-android@~6.2.2
      Adding xmldom project...
      Error: Your xmldom platform does not have Api.js

      In the above example, cordova is installed in the same directory as where cordova-fetch stores them. The error I originally encountered, can be triggered using the following commands:

      $ rm -r platforms/ plugins/ node_modules/
      $ PATH="$(npm -g prefix)/lib/node_modules/cordova/bin:$PATH" cordova platform add android
      Using cordova-fetch for cordova-android@^6.2.3
      Error: Platform android already added.

      The example shows the error for the android platform, but the same error occurs when using cordova-ios.




            • Assignee:
              remcohaszing Remco Haszing
            • Votes:
              0 Vote for this issue
              2 Start watching this issue


              • Created: