Cannot run init for a project using a non-JSON configuration file


Not able to create android build getting above error

“devDependencies”: {
@angular-devkit/build-angular”: “~13.2.3”,
@angular-eslint/builder”: “~13.0.1”,
@angular-eslint/eslint-plugin”: “~13.0.1”,
@angular-eslint/eslint-plugin-template”: “~13.0.1”,
@angular-eslint/template-parser”: “~13.0.1”,
@angular/cli”: “~13.2.3”,
@angular/compiler”: “~13.2.2”,
@angular/compiler-cli”: “~13.2.2”,
@angular/language-service”: “~13.2.2”,
@capacitor/cli”: “3.6.0”,
@ionic/angular-toolkit”: “^6.0.0”,
@types/jasmine”: “~3.6.0”,
@types/jasminewd2”: “~2.0.3”,
@types/node”: “^12.11.1”,
@typescript-eslint/eslint-plugin”: “5.3.0”,
@typescript-eslint/parser”: “5.3.0”,
“eslint”: “^7.6.0”,
“eslint-plugin-import”: “2.22.1”,
“eslint-plugin-jsdoc”: “30.7.6”,
“eslint-plugin-prefer-arrow”: “1.2.2”,
“jasmine-core”: “~3.8.0”,
“jasmine-spec-reporter”: “~5.0.0”,
“karma”: “~6.3.2”,
“karma-chrome-launcher”: “~3.1.0”,
“karma-coverage”: “~2.0.3”,
“karma-coverage-istanbul-reporter”: “~3.0.2”,
“karma-jasmine”: “~4.0.0”,
“karma-jasmine-html-reporter”: “^1.5.0”,
“protractor”: “~7.0.0”,
“ts-node”: “~8.3.0”,
“typescript”: “~4.4.4”
},
“description”: “An Ionic project”
}

what command did you run to get that message?
looks like you are trying to run init command in a project that is already init and that’s not possible if you have a capacitor.config.ts file
you can remove the file and run init again, or not run init since you already ran it

1 Like

The error is reproducible on running

ionic cap sync

@capacitor/cli”: “4.1.0”,

On my Project, this is reproducible after migrating to ionic 6 and angular 14.

When we run ionic cap sync, it updates few stuff and then The error message is displayed as below:

+ @capacitor/status-bar@4.0.1
+ @capacitor/app@4.0.1
+ @capacitor/haptics@4.0.1
+ @capacitor/keyboard@4.0.1
updated 4 packages and audited 1533 packages in 14.179s

175 packages are looking for funding
  run `npm fund` for details

found 6 vulnerabilities (2 moderate, 3 high, 1 critical)
  run `npm audit fix` to fix them, or `npm audit` for details
> capacitor.cmd init ancientsciencexxx --web-dir www
[error] Cannot run init for a project using a non-JSON configuration file.
        Delete capacitor.config.ts and try again.
[ERROR] An error occurred while running subprocess capacitor.

        capacitor.cmd init  --web-dir www exited with exit code 1.

        Re-running this command with the --verbose flag may provide more information.
1 Like

You can’t run init on a project that has been already init, looks like a bug on Ionic CLI running init when it shouldn’t.

2 Likes