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

Most upvoted comments

Still broken for me

node_modules/browserslist/update-db.js:49
    if (match[1]) return match[1]
             ^

TypeError: Cannot read property '1' of null
    at getCurrentVersion (node_modules/browserslist/update-db.js:49:14)
    at updateDB (node_modules/browserslist/update-db.js:119:17)
    at Object.<anonymous> (node_modules/browserslist/cli.js:40:3)
    at Module._compile (node:internal/modules/cjs/loader:1092:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1121:10)
    at Module.load (node:internal/modules/cjs/loader:972:32)
    at Function.Module._load (node:internal/modules/cjs/loader:813:14)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
    at node:internal/main/run_main_module:17:47

Still broken.

This is still broken.

Try npx browserslist@latest --update-db to be sure that the latest version was used (npx is tricky).

If you still have a problem. Please send PR. I do not have Windows to create a fix.

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:

$ npx browserslist@latest --update-db
npx: installed 6 in 1.588s
Cannot read property '1' of null

@BeisiXiong call it with npx even if you are using Yarn.

Try npx browserslist@latest --update-db to be sure that the latest version was used (npx is 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.