Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

browserslist package not detected with yarn #47

Open
BoGnY opened this issue Jan 7, 2025 · 4 comments
Open

browserslist package not detected with yarn #47

BoGnY opened this issue Jan 7, 2025 · 4 comments

Comments

@BoGnY
Copy link

BoGnY commented Jan 7, 2025

I've tried to run yarn dlx update-browserslist-db@latest but I get the following error:

➤ YN0000: · Yarn 4.5.3
➤ YN0000: ┌ Resolution step
➤ YN0085: │ + update-browserslist-db@npm:1.1.1, escalade@npm:3.2.0, picocolors@npm:1.1.1
➤ YN0000: └ Completed in 0s 258ms
➤ YN0000: ┌ Post-resolution validation
➤ YN0002: │ root-workspace-0b6124@workspace:. doesn't provide browserslist (pa02ec), requested by update-browserslist-db.
➤ YN0086: │ Some peer dependencies are incorrectly met by your project; run yarn explain peer-requirements <hash> for details, where <hash> is the six-letter p-prefixed code.
➤ YN0000: └ Completed
➤ YN0000: ┌ Fetch step
➤ YN0013: │ 3 packages were added to the project (+ 37.6 KiB).
➤ YN0000: └ Completed
➤ YN0000: ┌ Link step
➤ YN0000: └ Completed
➤ YN0000: · Done with warnings in 0s 311ms

Latest version:     1.0.30001690
Updating caniuse-lite version
$ yarn up -R caniuse-lite
caniuse-lite has been successfully updated

Error: update-browserslist-db tried to access browserslist (a peer dependency) but it isn't provided by your application; this makes the require call ambiguous and unsound.

Required package: browserslist
Required by: update-browserslist-db@virtual:dc3fc578bfa5e06182a4d2be39ede0bc5b74940b1ffe0d70c26892ab140a4699787750fba175dc306292e80b4aa2c8c5f68c2a821e69b2c37e360c0dff36ff66#npm:1.1.1 (via C:\Users\Luca\AppData\Local\Temp\xfs-ddf9ab0a\dlx-21912\.yarn\__virtual__\update-browserslist-db-virtual-06cd985fe4\0\cache\update-browserslist-db-npm-1.1.1-16e34017b1-536a2979ad.zip\node_modules\update-browserslist-db\)
Ancestor breaking the chain: root-workspace-0b6124@workspace:.


Require stack:
- C:\Users\Luca\AppData\Local\Temp\xfs-ddf9ab0a\dlx-21912\.yarn\__virtual__\update-browserslist-db-virtual-06cd985fe4\0\cache\update-browserslist-db-npm-1.1.1-16e34017b1-536a2979ad.zip\node_modules\update-browserslist-db\index.js 
- C:\Users\Luca\AppData\Local\Temp\xfs-ddf9ab0a\dlx-21912\.yarn\__virtual__\update-browserslist-db-virtual-06cd985fe4\0\cache\update-browserslist-db-npm-1.1.1-16e34017b1-536a2979ad.zip\node_modules\update-browserslist-db\cli.js   
    at require$$0.Module._resolveFilename (C:\Users\Luca\AppData\Local\Temp\xfs-ddf9ab0a\dlx-21912\.pnp.cjs:5676:13)
    at Module._load (node:internal/modules/cjs/loader:984:27)
    at require$$0.Module._load (C:\Users\Luca\AppData\Local\Temp\xfs-ddf9ab0a\dlx-21912\.pnp.cjs:5567:31)
    at Module.require (node:internal/modules/cjs/loader:1231:19)
    at require (node:internal/modules/helpers:179:18)
    at getBrowsers (C:\Users\Luca\AppData\Local\Temp\xfs-ddf9ab0a\dlx-21912\.yarn\__virtual__\update-browserslist-db-virtual-06cd985fe4\0\cache\update-browserslist-db-npm-1.1.1-16e34017b1-536a2979ad.zip\node_modules\update-browserslist-db\index.js:90:22)
    at updateDB (C:\Users\Luca\AppData\Local\Temp\xfs-ddf9ab0a\dlx-21912\.yarn\__virtual__\update-browserslist-db-virtual-06cd985fe4\0\cache\update-browserslist-db-npm-1.1.1-16e34017b1-536a2979ad.zip\node_modules\update-browserslist-db\index.js:287:15)
    at Object.<anonymous> (C:\Users\Luca\AppData\Local\Temp\xfs-ddf9ab0a\dlx-21912\.yarn\__virtual__\update-browserslist-db-virtual-06cd985fe4\0\cache\update-browserslist-db-npm-1.1.1-16e34017b1-536a2979ad.zip\node_modules\update-browserslist-db\cli.js:34:5)
    at Module._compile (node:internal/modules/cjs/loader:1369:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1427:10)

Problem with browser list retrieval.
Target browser changes won’t be shown.

I've tried to add browserslist to package.json (previously not included but only required by autoprefixer) but nothing changes

@ai
Copy link
Member

ai commented Jan 7, 2025

Seems like you also have monorepo.

Sorry, this issue is related to a complex environment reproduction.

You need to debug it on your machine and find a fix.

@BoGnY
Copy link
Author

BoGnY commented Jan 8, 2025

No it's not a monorepo.

I can reproduce with this package.json:

{
    "name": "test",
    "packageManager": "[email protected]",
    "devDependencies": {
        "autoprefixer": "^10.4.2",
        "browserslist": "^4.24.3",
        "postcss": "^8.4.14"
    }
}

EDIT: Just tried with an empty dockerized env with only node 20, corepack enabled and yarn 4.6.0 installed, to see if is my env or not, but I've got the same problem.

docker run -it --entrypoint bash node:20

and inside shell:

cd /home/node
corepack enable
yarn init
yarn add autoprefixer browserslist -D
yarn dlx update-browserslist-db@latest

@ai
Copy link
Member

ai commented Jan 8, 2025

Yes, seems like we have a problem with new Yarn.

But don’t worry. It is not a big error. It is an error in a system which shows browser diff before/after update. You can use tool without this diff.

I made this message less aggressive 8060322

If somebody will know a way to fix it properly for Yarn, please send PR.

@BoGnY
Copy link
Author

BoGnY commented Jan 9, 2025

The problem is at L90 of index.js, caused by require('browserslist')..

yarn dlx commands are executed on a virtual root workspace which miss the browserslist package and cannot be accessed to add manually the missing package.. maybe including a workspace section on package.json could be fix it, IDK I'm a backend dev so I know very low frontend languages..

For now I have found a workaround using the command yarn dlx -p browserslist -p update-browserslist-db update-browserslist-db which install the specified packages (inside virtual root workspace) before executing the script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants