Badly formed capacitor.config.json

Hi all,
I’m getting the above error for a build which has previously worked, and I’m looking for some help please!

The relevant log lines are:

2022-12-01 15:49:07,335 - Output: 
2022-12-01 15:49:07,373 - Output: Running with compiled app
{"__esModule":true,"default":{"appId":"com.xxx.xxx","appName":"xxx","webDir":"dist","bundledWebRuntime":false,"plugins":{"FirebaseAuthentication":{"providers":["google.com"]}}}}

2022-12-01 15:49:07,373 - Badly formed capacitor.config.json
Expecting value: line 1 column 1 (char 0)
2022-12-01 15:49:07,374 - Build failed 8427042f-d11d-4451-a766-ee03d4637df2

I’m using capacitor.config.ts in the root folder, so the only json versions are in .\android\app\src\main\assets\capacitor.config.json

This version worked previously:

{
	"appId": "com.xxx.xxx",
	"appName": "xxx",
	"webDir": "dist",
	"bundledWebRuntime": false,
	"plugins": {
		"CapacitorUpdater": {
			"autoUpdate": true
		},
		"FirebaseAuthentication": {
			"providers": [
				"google.com"
			]
		}
	}
}

This is the version that’s failing:

{
	"appId": "com.xxx.xxx",
	"appName": "xxx",
	"webDir": "dist",
	"bundledWebRuntime": false,
	"plugins": {
		"FirebaseAuthentication": {
			"providers": [
				"google.com"
			]
		}
	}
}

Both files check out as valid on jsonlint.com

Any thoughts?

Regards,
Andy

I looked at our logs. There’s a bit more to the file:

import { CapacitorConfig } from '@capacitor/cli'

const config: CapacitorConfig = {
    appId: 'xxx',
    appName: 'yyy',
    webDir: 'dist',
    bundledWebRuntime: false,
    plugins: {
        CapacitorUpdater: {
            autoUpdate: true,
        },
        FirebaseAuthentication: {
            providers: ['google.com'],
        },
    },
}

if (process.env.IONIC_LOCAL_SERVER == '1') {
    config.server = {
        url: 'http://zzz',
        cleartext: true,
    }
}

export default config

See the comma after cleartext: true?

Ah thanks. That’s a bit confusing given it points to me to the JSON file.

OK, now I’m away to find out how to stop VS code adding trailing commas :slight_smile:

Thanks so much for the very quick response. I’m impressed!

Andy

Yeah, Capacitor has several different ways to create capacitor.config.json. It can be from a .ts, .js, or even a .json file.

In your project, it’s a .ts.