Browserslist: npx browserslist@latest --update-db does not work with yarn workspaces

Created on 2 Nov 2020  路  5Comments  路  Source: browserslist/browserslist

Running npx browserslist@latest --update-db in the project root:

npx: installed 5 in 1.579s
Current version: 1.0.30001154
New version: 1.0.30001154
Removing old caniuse-lite from lock file
Installing new caniuse-lite version
$ yarn add caniuse-lite
error Running this command will add the dependency to the workspace root rather than the workspace itself, which might not be what you want - if you really meant it, make it explicit by running this command again with the -W flag (or --ignore-workspace-root-check).
Error: Command failed: yarn add caniuse-lite
error Running this command will add the dependency to the workspace root rather than the workspace itself, which might not be what you want - if you really meant it, make it explicit by running this command again with the -W flag (or --ignore-workspace-root-check).

Running npx browserslist@latest --update-db inside a workspace:

npx: installed 5 in 1.576s
No lockfile found. Run "npm install", "yarn install" or "pnpm install"

Workaround

Note: this isn't necessary anymore after https://github.com/browserslist/browserslist/pull/553

  1. Run npx browserslist@latest --update-db in the project root, let it fail
  2. Run yarn add caniuse-lite && yarn remove caniuse-lite inside the workspace

Most helpful comment

Adding -W doesn't break if you're not inside a workspace. Just tested it:

 ~/Development/nay => yarn add -W caniuse-lite
yarn add v1.22.10
[1/5] Validating package.json...
[2/5] Resolving packages...
[3/5] Fetching packages...
[...]
[4/5] Linking dependencies...
[5/5] Building fresh packages...
success Saved lockfile.
success Saved 1 new dependency.
info Direct dependencies
鈹斺攢 [email protected]
info All dependencies
鈹斺攢 [email protected]
Done in 3.05s.
 ~/Development/nay => yarn remove -W caniuse-lite
yarn remove v1.22.10
[1/2] Removing module caniuse-lite...
[2/2] Regenerating lockfile and installing missing dependencies...
[...]
success Uninstalled packages.
Done in 3.03s.

All 5 comments

Can you send a PR? I will not have time for Browserslist during this month.

It's basically the matter of adding -W to the install script if it's yarn here: https://github.com/browserslist/browserslist/blob/6e1fc4cf93ad6ec128650dc3b7d2a670a375234d/update-db.js#L140

Not quite sure what happens with -W if the project isn't a workspace though, so that'd need to be tested.

If no one has created a PR when I get off work in 8 hours I could add it.

Adding -W doesn't break if you're not inside a workspace. Just tested it:

 ~/Development/nay => yarn add -W caniuse-lite
yarn add v1.22.10
[1/5] Validating package.json...
[2/5] Resolving packages...
[3/5] Fetching packages...
[...]
[4/5] Linking dependencies...
[5/5] Building fresh packages...
success Saved lockfile.
success Saved 1 new dependency.
info Direct dependencies
鈹斺攢 [email protected]
info All dependencies
鈹斺攢 [email protected]
Done in 3.05s.
 ~/Development/nay => yarn remove -W caniuse-lite
yarn remove v1.22.10
[1/2] Removing module caniuse-lite...
[2/2] Regenerating lockfile and installing missing dependencies...
[...]
success Uninstalled packages.
Done in 3.03s.

The fix was released in 4.14.7

Was this page helpful?
0 / 5 - 0 ratings

Related issues

galvarez421 picture galvarez421  路  10Comments

timreichen picture timreichen  路  5Comments

shellscape picture shellscape  路  6Comments

equinusocio picture equinusocio  路  3Comments

lukejagodzinski picture lukejagodzinski  路  5Comments