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

Error thrown when `npm` is not installed #12

Closed Hyzual closed 1 year ago

Hyzual commented 1 year ago

Hi, I'm using pnpm and trying to update my browserslist db. I tried running $ pnpm dlx update-browserslist-db but it throws an error because it tries to run npm at some point:

/home/myuser/.local/share/pnpm/store/v3/tmp/dlx-415634/node_modules/.pnpm/update-browserslist-db@1.0.9/node_modules/update-browserslist-db/cli.js:39
      throw e
      ^

Error: Command failed: npm show caniuse-lite --json
    at checkExecSyncError (node:child_process:871:11)
    at Object.execSync (node:child_process:943:15)
    at getLatestInfo (/home/jmasson/.local/share/pnpm/store/v3/tmp/dlx-415634/node_modules/.pnpm/update-browserslist-db@1.0.9/node_modules/update-browserslist-db/index.js:72:18)
    at updateDB (/home/jmasson/.local/share/pnpm/store/v3/tmp/dlx-415634/node_modules/.pnpm/update-browserslist-db@1.0.9/node_modules/update-browserslist-db/index.js:259:16)
    at Object.<anonymous> (/home/jmasson/.local/share/pnpm/store/v3/tmp/dlx-415634/node_modules/.pnpm/update-browserslist-db@1.0.9/node_modules/update-browserslist-db/cli.js:34:5)
    at Module._compile (node:internal/modules/cjs/loader:1119:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1173:10)
    at Module.load (node:internal/modules/cjs/loader:997:32)
    at Module._load (node:internal/modules/cjs/loader:838:12)

I don't have npm installed which explains why the command fails. From quickly reading the code it looks like this command has a yarn version but not a pnpm one. Is there a workaround to this issue ?

https://github.com/browserslist/update-db/blob/dd50e379d141a0bf4c259a2bc07d3bc1e68705f7/index.js#L59-L72

ai commented 1 year ago

No, we need to add pnpm code here.

Can I ask you to send PR? I am now locked on another open source project. It will be easy.