browserslist / update-db

CLI tool to update caniuse-lite to refresh target browsers from Browserslist config
https://browsersl.ist/
MIT License
286 stars 57 forks source link

Unexpected token { in JSON at position 95 #17

Closed ckhatton-transreport closed 1 year ago

ckhatton-transreport commented 1 year ago

I've simply run npx browserslist@latest --update-db and got the error:

SyntaxError: Unexpected token { in JSON at position 95
    at JSON.parse (<anonymous>)
    at getLatestInfo (/Users/foobar/.npm/_npx/072487b38308305a/node_modules/update-browserslist-db/index.js:62:19)
    at updateDB (/Users/foobar/.npm/_npx/072487b38308305a/node_modules/update-browserslist-db/index.js:264:16)
    at Object.<anonymous> (/Users/foobar/.npm/_npx/072487b38308305a/node_modules/browserslist/cli.js:42:3)

Maybe an additional curly brace has been added to the latest build by mistake?

ai commented 1 year ago

Check yarn info caniuse-lite --json output. The error happens because yarn outputs incorrect JSON.

ckhatton-transreport commented 1 year ago

Ar, I didn't realise browserslist is local, not global. Yeah the related project repo uses yarn.

I have put the output through an online JSON checker, and it reports nothing is wrong with it.

🤷

ckhatton-transreport commented 1 year ago

Oh weird, running npx browserslist@latest --update-db again has worked successfully, with warnings, but it worked.

✦ ❯ npx browserslist@latest --update-db
Latest version:     1.0.30001466
Installed version:  1.0.30001323
Removing old caniuse-lite from lock file
Installing new caniuse-lite version

Thank you for the help and jumping onto the issue ticket quick.