browserslist: Cannot --update-db with Yarn on Windows
It looks like the database updater is sensitive to line endings and, unfortunately for this project, Yarn on Windows has chosen to use Windows line endings:
PS REDACTED> yarn browserslist --update-db
yarn run v1.22.5
$ REDACTED\node_modules\.bin\browserslist --update-db
REDACTED\node_modules\browserslist\update-db.js:49
if (match[1]) return match[1]
^
TypeError: Cannot read property '1' of null
at getCurrentVersion (REDACTED\node_modules\browserslist\update-db.js:49:14)
at updateDB (REDACTED\node_modules\browserslist\update-db.js:119:17)
at Object.<anonymous> (REDACTED\node_modules\browserslist\cli.js:40:3)
at Module._compile (internal/modules/cjs/loader.js:1137:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
at Module.load (internal/modules/cjs/loader.js:985:32)
at Function.Module._load (internal/modules/cjs/loader.js:878:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47
error Command failed with exit code 1.
If I re-save the yarn.lock with LF instead of CRLF, it’s fine.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 6
- Comments: 27 (11 by maintainers)
Commits related to this issue
- Allow Windows line endings in yarn.lock Fixes #531 — committed to twpol/browserslist by twpol 4 years ago
- Allow Windows line endings in yarn.lock (#532) Fixes #531 — committed to browserslist/browserslist by twpol 4 years ago
- Squashed commit of the following: commit 7c7ef17f56862f2deb33ae759bbd7089505a50a8 Author: zhouyu9527 <76467835+zhouyu9527@users.noreply.github.com> Date: Tue Jul 5 09:51:03 2022 +0800 Squashed... — committed to zhouyu9527/browserslist by zhouyu9527 2 years ago
- Allow Windows line endings in yarn.lock (#532) Fixes #531 — committed to zhouyu9527/browserslist by twpol 4 years ago
Still broken for me
Still broken.
This is still broken.
hello, may I ask can I run this command npx browserslist@latest --update-db with yarn?
still broken on Windows and yarn as of today
@Petah - I think this might be because you don’t have a browserlist entry in your package.json. I was seeing that error and that was the reason for me.
Was there a solution to this? Getting this on Mac:
@BeisiXiong call it with
npxeven if you are using Yarn.Try
npx browserslist@latest --update-dbto be sure that the latest version was used (npxis tricky).If you still have a problem. Please send PR. I do not have Windows to create a fix.
The fix was released in 4.14.2.
@twpol Can you help me with fixing RegExp and send PR? I don’t have Windows to test that everything is OK.