SyntaxError: Unexpected token U in JSON at position 0
at JSON.parse () at Integration.getCapacitorCLIConfig.lodash.memoize (/usr/local/lib/node_modules/@ionic/cli/lib/integrations/capacitor/index.js:33:25)
SyntaxError: Unexpected token U in JSON at position 0
at JSON.parse () at Integration.getCapacitorCLIConfig.lodash.memoize (/usr/local/lib/node_modules/@ionic/cli/lib/integrations/capacitor/index.js:33:25)
I've been having the same problem. I was able to solve it by upgrading the project version of capacitor.
The previous versions of the capacitor capacitor/cli
and capacitor/core
were 1.4.0, I was able to solve it by upgrading them (and capacitor/android
and capacitor/ios
) to:
"dependencies": {
...
"@capacitor/android": "^2.4.5",
"@capacitor/core": "^2.4.5",
"@capacitor/ios": "^2.4.5"
},
"devDependencies": {
...
"@capacitor/cli": "2.4.5"
}
Maybe you should upgrade your global ionic/cli
version too, mine is 6.16.1.
After upgrading the versions on the project, the capacitor commands worked fine for me.
Upgrade capacitor last version npm install @capacitor/cli@latest @capacitor/core@latest
Tried upgrading my ionic/cli, capacitor version to the latest but after a circus of missing dependencies I uninstalled ionic/cli and installed a previous stable version 6.11.0 and worked perfect for me.
In my case I was using ionic v6
with capacitor/cli and capacitor/core v2.4.0
. Downgrading the ionic cli to v5
fixed it for me.
npm uninstall -g @ionic/cli
npm install -g ionic@5