skip to Main Content

I am getting a Cannot load empty config.xml file when I try to run ionic cordova in Visual Studio Code. And

ionic integrations enable cordova --add

doesn’t work. How can I fix this problem ?

I tried

ionic integrations enable cordova --add 

several times and it doesn’t work.

After that I delete and re-install the platform with cordova add platform android and I got the Error Cannot load Cordova config.INVALID_PACKAGE_JSON. To get rid of the invalid Json I used npm init and now, after running ionic cordova build I get the error

Cannot run sass task: missing in gulpfile.js

the package.json

{
    "name": "test",
    "version": "0.0.1",
    "author": "test",
    "homepage": "http://test.com/",
    "private": true,
    "scripts": {
        "clean": "ionic-app-scripts clean",
        "build": "ionic-app-scripts build",
        "lint": "ionic-app-scripts lint",
        "ionic:build": "ionic-app-scripts build",
        "ionic:serve": "ionic-app-scripts serve",
        "ng-swagger-gen": "ng-swagger-gen -c swagger-gen/ng-swagger-gen.conf.json"
    },
"devDependencies": {
        "@ionic/app-scripts": "3.2.3",
        "com-sarriaroman-photoviewer": "file:plugin-src/com-sarriaroman-photoviewer",
        "cordova-android": "^11.0.0",
        "cordova-ios": "^6.2.0",
        "cordova-plugin-badge": "file:plugin-src/cordova-plugin-badge",
        "cordova-plugin-camera": "^6.0.0",
        "cordova-plugin-file": "^7.0.0",
        "cordova-plugin-file-transfer": "git+https://github.com/apache/cordova-plugin-file-transfer.git",
        "cordova-plugin-ionic-webview": "^5.0.0",
        "cordova-plugin-local-notification": "file:plugin-src/cordova-plugin-local-notification",
        "cordova-plugin-media": "file:plugin-src/cordova-plugin-media",
        "cordova-plugin-safariviewcontroller": "^2.0.0",
        "cordova-sqlite-storage": "^6.0.0",
        "cordova.plugins.diagnostic": "^6.0.4",
        "ng-swagger-gen": "0.11.4",
        "typescript": "2.6.2"
    },

}

2

Answers


  1. To install cordova use:

    npm install -g cordova

    To add corova in your project:

    ionic integrations enable cordova –add

    Login or Signup to reply.
  2. I’m sorry to hear that. Let’s start from the beginning and work upwards from that. We’ll start with your first problem you mentioned in your post,

    The first error indicates that the Cordova config in your project is either broken or empty. To fix this, you can try regenerating the config.xml file by running the following command:

    ionic integrations enable cordova --add
    

    Now regarding your second issue,

    If this command does not work (as you mentioned), you can try manually creating a new config.xml file in the root directory of your project and populating it with the appropriate values. Here is an example config.xml file that you can use as a starting point (simplified version of a gist):

    <?xml version='1.0' encoding='utf-8'?>
    <widget id="your.app.id" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
      <name>Your App Name</name>
      <description>Your app description.</description>
      <author email="[email protected]" href="http://example.com">Your Name</author>
      <content src="index.html" />
      <access origin="*" />
    </widget>
    

    Make sure to replace the id, name, description, and author fields with your own values before running your app.

    Now, regarding the Cannot run sass task: missing in gulpfile.js error you mentioned, it may indicate that your project is missing the Gulp build tool. You can try installing Gulp by running the following command:

    npm install --save-dev gulp
    

    After that, make sure you have a gulpfile.js file in your root project directory. Here is an example gulpfile.js that you can use as a starting point and build off of:

    var gulp = require('gulp');
    var sass = require('gulp-sass');
    
    gulp.task('sass', function () {
      return gulp.src('./scss/**/*.scss')
        .pipe(sass().on('error', sass.logError))
        .pipe(gulp.dest('./www/css'));
    });
    
    gulp.task('sass:watch', function () {
      gulp.watch('./scss/**/*.scss', ['sass']);
    });
    

    This gulpfile defines a sass task that compiles your scss files and outputs the resulting CSS to the www/css directory. It also defines sass:watch task that watches for changes to your scss files and automatically recompiles them.

    Once you have done all of this, try running ionic cordova build again and see if the error persists.

    If it still persists, it may be time to recreate your project and retry the steps above.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search