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
To install cordova use:
To add corova in your project:
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: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 exampleconfig.xml
file that you can use as a starting point (simplified version of a gist):Make sure to replace the
id
,name
,description
, andauthor
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:After that, make sure you have a
gulpfile.js
file in your root project directory. Here is an examplegulpfile.js
that you can use as a starting point and build off of:This gulpfile defines a sass task that compiles your scss files and outputs the resulting CSS to the
www/css
directory. It also definessass: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.