Closed LeonMelis closed 1 year ago
Can you debug the code to find why package manager started to output incorrect JSON?
Well, this is very awkward, I ran npx update-browserslist-db@latest
with a debugger attached using IntelliJ... and it installed flawlessly... I guess that makes this a Heisenbug then?
However, when observing met yarn.lock
file, it appeared that npx update-browserslist-db@latest
had downgraded hundreds of babel related packages (from 7.19.x to 7.16.x), and rewritten a lot of packages with npm repositories instead of yarn... 🤔 I guess that is just the current JS dependency mess we'll have to live with, but it might be that there is some incompatibility with later Babel versions?
I recommend just moving to pnpm, the only good package manager.
2021: Just use npm! It's so much better! 2022: Just use yarn! It's so much better! 2023: Just use pnpm! It's so much better!
Sorry for the rant, but the JS ecosystem has become a terrible mess, I'm just tired of it.
For anyone else running into this problem, you can add the following to the scripts section of your package.json
"script": {
...
"npx": "npx"
}
Then run ~npm~ ~yarn~, sorry, I mean pnpm npx update-browserslist-db@latest
and it should work, if you are lucky.
I'll close this ticket, I don't think there is anything else we can do here.
Just an fyi that pnpm dlx
is pnpm's equivalent of npx
in transient download mode. Defining the "npx"
script—or calling npx
at all, for that matter—shouldn't be necessary when using pnpm.
It's happening to me with npm (v10.2.0 and v10.2.1) and bun (v1.0.6) on Ubuntu 22.04.3. Can you please reopen this issue ?
@lionel-bijaoui with Bun it is a different issue. We already have it.
Somebody need to send PR with Bun support.
The error message is the same across npm and bun. I hope these details can help
npx update-browserslist-db@latest
<censored>/node_modules/update-browserslist-db/cli.js:39
throw e
^
SyntaxError: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at getLatestInfo (<censored>/.npm/_npx/2662cbd72e57abb6/node_modules/update-browserslist-db/index.js:73:15)
at updateDB (<censored>.npm/_npx/2662cbd72e57abb6/node_modules/update-browserslist-db/index.js:272:16)
at Object.<anonymous> (<censored>/.npm/_npx/2662cbd72e57abb6/node_modules/update-browserslist-db/cli.js:34:5)
at Module._compile (node:internal/modules/cjs/loader:1256:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
at Module.load (node:internal/modules/cjs/loader:1119:32)
at Module._load (node:internal/modules/cjs/loader:960:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:86:12)
at node:internal/main/run_main_module:23:47
Node.js v18.18.0
bunx update-browserslist-db@latest
/tmp/update-browserslist-db@latest--bunx/node_modules/update-browserslist-db/cli.js:39
throw e
^
SyntaxError: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at getLatestInfo (/tmp/update-browserslist-db@latest--bunx/node_modules/update-browserslist-db/index.js:73:15)
at updateDB (/tmp/update-browserslist-db@latest--bunx/node_modules/update-browserslist-db/index.js:272:16)
at Object.<anonymous> (/tmp/update-browserslist-db@latest--bunx/node_modules/update-browserslist-db/cli.js:34:5)
at Module._compile (node:internal/modules/cjs/loader:1256:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
at Module.load (node:internal/modules/cjs/loader:1119:32)
at Module._load (node:internal/modules/cjs/loader:960:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:86:12)
at node:internal/main/run_main_module:23:47
Node.js v18.18.0
Is there a way to do the update manually ? What are the steps ? I only need to update caniuse-lite
to it's latest version ?
Thank you for your help !
The error message is equal but the reason is different.
I am not Bun user, you need to find out yourself and then help other sending PR.
Remember, open source is not a free support but rather collective way to help each other where everyone is contributing something.
I'm sorry for the confusion about bun. I also and more importantly have the same error with NPM.
I have updated to node 20 and the error disappeared.
Have a great day !
I'm trying to update browserlist, but the update script fails.
I tried both
npx update-browserslist-db@latest
andnpx browserslist@latest --update-db
, they both throw the same error:I tried removing the cache file at
/home/user/.npm
but to no avail. Am using node v16.18.1, npm 9.6.1 and yarn 1.22.19.I suspect a corrupt cache file somewhere, is there anything else I could purge?