0

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)

  • From this error, I can understand that you are attempting to parse undefined, which is not valid JSON. Check out this: https://stackoverflow.com/questions/46613243/uncaught-syntaxerror-unexpected-token-u-in-json-at-position-0 – Ani Jun 03 '21 at 06:58
  • Make sure your global and project version of CLIs match. – Ark Luis Jul 19 '21 at 14:18

4 Answers4

2

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.

buddemat
  • 4,552
  • 14
  • 29
  • 49
2

Upgrade capacitor last version npm install @capacitor/cli@latest @capacitor/core@latest

0

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.

Anthony Mutisya
  • 2,196
  • 1
  • 14
  • 5
0

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
yksolanki9
  • 429
  • 2
  • 7
  • 14