Repository: browserslist/browserslist (language: javascript)

Issue:
--update-db fails with Yarn v2 lock file
## Description
When using Yarn v2, running `npx browserslist@latest --update-db` fails with the error `Cannot read property '1' of null`.  Calling `yarn run browserslist --update-db` gives the error with some more details:

```
C:\inetpub\wwwroot\blt\.yarn\cache\browserslist-npm-4.16.1-37866cfd90-56f51464c3.zip\node_modules\browserslist\update-db.js:57
    if (match[1]) return match[1]
             ^

TypeError: Cannot read property '1' of null
    at getCurrentVersion (C:\inetpub\wwwroot\blt\.yarn\cache\browserslist-npm-4.16.1-37866cfd90-56f51464c3.zip\node_modules\browserslist\update-db.js:57:14)
    at updateDB (C:\inetpub\wwwroot\blt\.yarn\cache\browserslist-npm-4.16.1-37866cfd90-56f51464c3.zip\node_modules\browserslist\update-db.js:179:17)
    at Object.<anonymous> (C:\inetpub\wwwroot\blt\.yarn\cache\browserslist-npm-4.16.1-37866cfd90-56f51464c3.zip\node_modules\browserslist\cli.js:40:3)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.external_module_.Module._load (C:\inetpub\wwwroot\blt\.pnp.js:4980:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
    at internal/main/run_main_module.js:17:47
```

<details>
<summary>
<code>package.json</code>
</summary>
```json
{
  "name": "blt",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "dependencies": {
    "browserslist": "^4.16.1"
  }
}
```
</details>
<details>
<summary>
<code>yarn.lock</code>
</summary>
```yaml
# This file is generated by running "yarn install" inside your project.
# Manual changes might be lost - proceed with caution!

__metadata:
  version: 4
  cacheKey: 7

"blt@workspace:.":
  version: 0.0.0-use.local
  resolution: "blt@workspace:."
  dependencies:
    browserslist: ^4.16.1
  languageName: unknown
  linkType: soft

"browserslist@npm:^4.16.1":
  version: 4.16.1
  resolution: "browserslist@npm:4.16.1"
  dependencies:
    caniuse-lite: ^1.0.30001173
    colorette: ^1.2.1
    electron-to-chromium: ^1.3.634
    escalade: ^3.1.1
    node-releases: ^1.1.69
  bin:
    browserslist: cli.js
  checksum: 56f51464c3a3bd9b2aeb75ded1dc3fce5ad91bd6d84187aba812a78ba66b69bc97c2de25a1b7409daac3c0049e979bf0faa6cca4aacce0abcaf3107c250ce3fb
  languageName: node
  linkType: hard

"caniuse-lite@npm:^1.0.30001173":
  version: 1.0.30001177
  resolution: "caniuse-lite@npm:1.0.30001177"
  checksum: a43eafb57339093bf3343bc6f57cc21ff6779af44c9a26cc078c3b335db12598179d1333a1cbdd6fd25a2c08cfc550c78538b48fbb3e9c383f46460a1c32a1c0
  languageName: node
  linkType: hard

"colorette@npm:^1.2.1":
  version: 1.2.1
  resolution: "colorette@npm:1.2.1"
  checksum: 1cc21ad4b84777a424794f78b6bb6a44b614ae17dcea91762199339f8047598e6d981249eeef7ea588c99eaf062be8fcdcd4866c112998922ed854db6dde96f9
  languageName: node
  linkType: hard

"electron-to-chromium@npm:^1.3.634":
  version: 1.3.639
  resolution: "electron-to-chromium@npm:1.3.639"
  checksum: bf8b79e55d50ddcd55b029feb161a56250f3a8980b5c11b47055fd983b9306ad8c69c0501eef9317e0e03f8c5d69fecb97338c08df8c9456953f5741646794c1
  languageName: node
  linkType: hard

"escalade@npm:^3.1.1":
  version: 3.1.1
  resolution: "escalade@npm:3.1.1"
  checksum: 1e31ff50d66f47cd0dfffa702061127116ccf9886d1f54a802a7b3bc95b94cab0cbf5b145cc5ac199036df6fd9d1bb24af1fa1bfed87c94879e950fbee5f86d1
  languageName: node
  linkType: hard

"node-releases@npm:^1.1.69":
  version: 1.1.69
  resolution: "node-releases@npm:1.1.69"
  checksum: 240b2534f32c8bbdfefb1fb052d2b1c198f3a745141ce245c6c5241a6efefae22d356b66965e5250869013c3c4777050cdca78d39f3b46965166b5f3e02b08d7
  languageName: node
  linkType: hard
```
</details>

Here's a zip of the whole project (just `package.json` and various Yarn artifacts): [sscce.zip](https://github.com/browserslist/browserslist/files/5816478/sscce.zip)

If caniuse-lite isn't in package.json directly, `yarn info` fails
If `caniuse-lite` is included as as transitive dependency of some other package like NextJS, I'm finding that when I run `npx browserslist@latest --update-db` then it fails with this error:

```
Command failed: yarn info caniuse-lite --json
```

I use Yarn 3.0.1. When I add `caniuse-lite` directly, then instead of that error, I get:

```
Cannot read property 'version' of undefined
```

For reference, `yarn info caniuse-lite --json` returns:

```
{"value":"caniuse-lite@npm:1.0.30001252","children":{"Version":"1.0.30001252"}}
```

And if this were to work without `caniuse-lite` being installed as a direct dependency, the `yarn info` command just needs the `--recursive` flag:

```
yarn info caniuse-lite --recursive --json
```

Yielding the same result as above.

It seems that the `update-db` command doesn't work properly for Yarn Berry. I presume that even if I got past this, it would fail later due to #577 because it doesn't use `yarn up -R caniuse-lite` as suggested there.


Discussion / hints:
`--update-db` doesn’t have Yarn 2 support.

Do you want to send PR?
I took a look at implementing this, but the main issue I saw was that Yarn 2 expects a sha512 checksum of the package, which isn't readily available, that I can see.  I've asked about it [on the Yarn Discord](https://discord.com/channels/226791405589233664/654372321225605128/799410743946248273)
Why does browserslist use a custom command rather than `yarn upgrade` or `npm upgrade --depth=9999`?
@Timer I’d like to have a simple command. But both `yarn upgrade` and `npm update` will update all dependencies and will make `browserslist --update-db` a very dangerous move.

We need to update only `caniuse-lite` version because it is much safer for users.

I tried to find a command to do it but didn’t find a proper way to update all deep dependencies of `X` (and `X` only).
(Just linking these here to point out what Andrey says: there is a yarn feature request to upgrade only a specific package, and deeply/indirect-deps included https://github.com/yarnpkg/yarn/issues/4986 and [~yarnpkg/yarn#2394~ (closed)](https://github.com/yarnpkg/yarn/issues/2394). It's just not possible to deeply update dependencies for a specific package, or so it seems.)

For npm that would be `npm --depth 9999 update caniuse-lite`? 
It didn’t work before, but maybe the npm team fixed the command.

Can you create a simple test stand with outdated `caniuse-lite` in deep dependencies, run `npm --depth 9999 update caniuse-lite` and show me `package-lock.json` diff?

We can use this command in `--update-db` for the `npm` case.
At least for Yarn, we want to implement a `yarn up -R <name>` command that would upgrade the given package regardless where it is on the dependency tree (and only this one). If we had that, would `--update-db` just shell out to `yarn up -R caniuse-lite`?
@acusti yeap, we can call `yarn up -R caniuse-lite` in `--update-db` on Yarn 2 lock-file.

P. S. `yarn up -R *` is the only blocker for me from moving to Yarn 2 in my working project 😺
Just merged [`yarn up -R`](https://github.com/yarnpkg/berry/pull/2427). It will be released along with the next release (hopefully Yarn 3!) in a month or two (it can already be used now for people who build Yarn from sources, which is a [very easy thing](https://yarnpkg.com/cli/set/version/from/sources)).
Just went through 4 `caniuse-lite` and `yarn` issues with different workarounds, decided to use `npx browserslist@latest --update-db` and now I'm here with the same error. 😄 
For anyone looking for solutions, the common-needed `npx browserslist@latest --update-db` can be replaced with `yarn up -R caniuse-lite` when using Yarn2. 🙂
Can somebody send PR to `update-db.js` which will run `yarn up -R caniuse-lite`?
OK, I will use our [Cult of Martians](https://cultofmartians.com/) code learning task list to fix this
> It seems that the update-db command doesn't work properly for Yarn Berry.

Yeap. We didn’t add Yarn Berry support, because it was not possible.

Now we have `yarn up -R caniuse-lite`, but don’t have time to implement it.

Can you send PR with Yarn version detection and calling `yarn up -R caniuse-lite` for Yarn 3?

Fix patch:
diff --git a/.gitignore b/.gitignore
index cec12218..28460afb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
 node_modules/
+.yarn/
 npm-debug.log
 yarn-error.log
 
diff --git a/update-db.js b/update-db.js
index e8728db0..3fff1733 100644
--- a/update-db.js
+++ b/update-db.js
@@ -42,11 +42,29 @@ function detectLockfile () {
   )
 }
 
+function detectLockfileVersion (lock) {
+  if (lock.mode === 'yarn') {
+    lock.version = 1
+    lock.content = fs.readFileSync(lock.file).toString()
+    var isVersion1 = lock.content.search(/# yarn lockfile v1/g)
+    if (isVersion1 === -1) {
+      lock.version = 2
+    }
+  }
+  return lock
+}
+
 function getLatestInfo (lock) {
   if (lock.mode === 'yarn') {
-    return JSON.parse(
-      childProcess.execSync('yarn info caniuse-lite --json').toString()
-    ).data
+    if (lock.version === 1) {
+      return JSON.parse(
+        childProcess.execSync('yarn info caniuse-lite --json').toString()
+      ).data
+    } else {
+      return JSON.parse(
+        childProcess.execSync('yarn npm info caniuse-lite --json').toString()
+      )
+    }
   }
   return JSON.parse(
     childProcess.execSync('npm show caniuse-lite --json').toString()
@@ -197,21 +215,7 @@ function updateLockfile (lock, latest) {
   return updatePnpmLockfile(lock, latest)
 }
 
-module.exports = function updateDB (print) {
-  var lock = detectLockfile()
-  var latest = getLatestInfo(lock)
-  var browsersListRetrievalError
-  var oldBrowsersList
-  try {
-    oldBrowsersList = getBrowsersList()
-  } catch (e) {
-    browsersListRetrievalError = e
-  }
-
-  print(
-    'Latest version:     ' + bold(green(latest.version)) + '\n'
-  )
-
+function updatePackageManually (print, lock, latest) {
   var lockfileData = updateLockfile(lock, latest)
   var caniuseVersions = Object.keys(lockfileData.versions).sort()
   if (caniuseVersions.length === 1 &&
@@ -260,6 +264,47 @@ module.exports = function updateDB (print) {
     yellow('$ ' + del + ' caniuse-lite') + '\n'
   )
   childProcess.execSync(del + ' caniuse-lite')
+}
+
+module.exports = function updateDB (print) {
+  var lock = detectLockfile()
+  lock = detectLockfileVersion(lock)
+  var latest = getLatestInfo(lock)
+
+  var browsersListRetrievalError
+  var oldBrowsersList
+  try {
+    oldBrowsersList = getBrowsersList()
+  } catch (e) {
+    browsersListRetrievalError = e
+  }
+
+  print(
+    'Latest version:     ' + bold(green(latest.version)) + '\n'
+  )
+
+  if (lock.mode === 'yarn' && lock.version !== 1) {
+    var update = 'yarn up -R'
+    print(
+      'Updating caniuse-lite version\n' +
+      yellow('$ ' + update + ' caniuse-lite') + '\n'
+    )
+    try {
+      childProcess.execSync(update + ' caniuse-lite')
+    } catch (e) /* istanbul ignore next */ {
+      print(
+        red(
+          '\n' +
+          e.stack + '\n\n' +
+          'Problem with `' + update + ' caniuse-lite` call. ' +
+          'Run it manually.\n'
+        )
+      )
+      process.exit(1)
+    }
+  } else {
+    updatePackageManually(print, lock, latest)
+  }
 
   print('caniuse-lite has been successfully updated\n')
 


Test patch:
diff --git a/test/fixtures/update-yarn-v2/package.json b/test/fixtures/update-yarn-v2/package.json
new file mode 100644
index 00000000..97360222
--- /dev/null
+++ b/test/fixtures/update-yarn-v2/package.json
@@ -0,0 +1,8 @@
+{
+  "license": "MIT",
+  "devDependencies": {
+    "autoprefixer": "^9.7.4",
+    "postcss-preset-env": "^6.7.0",
+    "qs": "^6.6.0"
+  }
+}
diff --git a/test/fixtures/update-yarn-v2/yarn.lock b/test/fixtures/update-yarn-v2/yarn.lock
new file mode 100644
index 00000000..6add2c7c
--- /dev/null
+++ b/test/fixtures/update-yarn-v2/yarn.lock
@@ -0,0 +1,672 @@
+# This file is generated by running "yarn install" inside your project.
+# Manual changes might be lost - proceed with caution!
+
+__metadata:
+  version: 4
+  cacheKey: 8
+
+"@csstools/convert-colors@npm:^1.4.0":
+  version: 1.4.0
+  resolution: "@csstools/convert-colors@npm:1.4.0"
+  checksum: 26069eeb845a506934c821c203feb97f5de634c5fbeb9978505a2271d6cfdb0ce400240fca9620a4ef2e68953928ea25aab92ea8454e0edf5cd074066d9ad57b
+  languageName: node
+  linkType: hard
+
+"ansi-styles@npm:^3.2.1":
+  version: 3.2.1
+  resolution: "ansi-styles@npm:3.2.1"
+  dependencies:
+    color-convert: ^1.9.0
+  checksum: d85ade01c10e5dd77b6c89f34ed7531da5830d2cb5882c645f330079975b716438cd7ebb81d0d6e6b4f9c577f19ae41ab55f07f19786b02f9dfd9e0377395665
+  languageName: node
+  linkType: hard
+
+"autoprefixer@npm:^9.6.1, autoprefixer@npm:^9.7.4":
+  version: 9.7.4
+  resolution: "autoprefixer@npm:9.7.4"
+  dependencies:
+    browserslist: ^4.8.3
+    caniuse-lite: ^1.0.30001020
+    chalk: ^2.4.2
+    normalize-range: ^0.1.2
+    num2fraction: ^1.2.2
+    postcss: ^7.0.26
+    postcss-value-parser: ^4.0.2
+  bin:
+    autoprefixer: bin/autoprefixer
+  checksum: 1d22b920142d1cb34313eabb484ea3f2e1262f054c93cc12d9f8fb1f90323ce320cd9ac9d3d160eafb76de681a12e03a670777847a533cd62ecd9c619b32e662
+  languageName: node
+  linkType: hard
+
+"balanced-match@npm:^1.0.0":
+  version: 1.0.0
+  resolution: "balanced-match@npm:1.0.0"
+  checksum: 9b67bfe558772f40cf743a3469b48b286aecec2ea9fe80c48d74845e53aab1cef524fafedf123a63019b49ac397760573ef5f173f539423061f7217cbb5fbd40
+  languageName: node
+  linkType: hard
+
+"browserslist@npm:^4.6.4, browserslist@npm:^4.8.3":
+  version: 4.9.1
+  resolution: "browserslist@npm:4.9.1"
+  dependencies:
+    caniuse-lite: ^1.0.30001030
+    electron-to-chromium: ^1.3.363
+    node-releases: ^1.1.50
+  bin:
+    browserslist: cli.js
+  checksum: 507ae83411c3c87e17c46affeb204444999f82a603959146e1daab72b950d53d28b782cb4cec7522fdd979cbd4a3c6b68d67fd3028df35241cacc70a0b12b409
+  languageName: node
+  linkType: hard
+
+"caniuse-lite@npm:^1.0.30000981, caniuse-lite@npm:^1.0.30001020, caniuse-lite@npm:^1.0.30001030":
+  version: 1.0.30001035
+  resolution: "caniuse-lite@npm:1.0.30001035"
+  checksum: c0dcc74bb843fafafb8034275d4a4960e89f43f838041e631d18c2225ec1d9225c049b3750517716f04ab8d20e4d500b57febde9ef03122cedddd41127461129
+  languageName: node
+  linkType: hard
+
+"chalk@npm:^2.4.2":
+  version: 2.4.2
+  resolution: "chalk@npm:2.4.2"
+  dependencies:
+    ansi-styles: ^3.2.1
+    escape-string-regexp: ^1.0.5
+    supports-color: ^5.3.0
+  checksum: ec3661d38fe77f681200f878edbd9448821924e0f93a9cefc0e26a33b145f1027a2084bf19967160d11e1f03bfe4eaffcabf5493b89098b2782c3fe0b03d80c2
+  languageName: node
+  linkType: hard
+
+"color-convert@npm:^1.9.0":
+  version: 1.9.3
+  resolution: "color-convert@npm:1.9.3"
+  dependencies:
+    color-name: 1.1.3
+  checksum: fd7a64a17cde98fb923b1dd05c5f2e6f7aefda1b60d67e8d449f9328b4e53b228a428fd38bfeaeb2db2ff6b6503a776a996150b80cdf224062af08a5c8a3a203
+  languageName: node
+  linkType: hard
+
+"color-name@npm:1.1.3":
+  version: 1.1.3
+  resolution: "color-name@npm:1.1.3"
+  checksum: 09c5d3e33d2105850153b14466501f2bfb30324a2f76568a408763a3b7433b0e50e5b4ab1947868e65cb101bb7cb75029553f2c333b6d4b8138a73fcc133d69d
+  languageName: node
+  linkType: hard
+
+"css-blank-pseudo@npm:^0.1.4":
+  version: 0.1.4
+  resolution: "css-blank-pseudo@npm:0.1.4"
+  dependencies:
+    postcss: ^7.0.5
+  bin:
+    css-blank-pseudo: cli.js
+  checksum: f995a6ca5dbb867af4b30c3dc872a8f0b27ad120442c34796eef7f9c4dcf014249522aaa0a2da3c101c4afa5d7d376436bb978ae1b2c02deddec283fad30c998
+  languageName: node
+  linkType: hard
+
+"css-has-pseudo@npm:^0.10.0":
+  version: 0.10.0
+  resolution: "css-has-pseudo@npm:0.10.0"
+  dependencies:
+    postcss: ^7.0.6
+    postcss-selector-parser: ^5.0.0-rc.4
+  bin:
+    css-has-pseudo: cli.js
+  checksum: 88d891ba18f821e8a94d821ecdd723c606019462664c7d86e7d8731622bd26f9d55582e494bcc2a62f9399cc7b89049ddc8a9d1e8f1bf1a133c2427739d2d334
+  languageName: node
+  linkType: hard
+
+"css-prefers-color-scheme@npm:^3.1.1":
+  version: 3.1.1
+  resolution: "css-prefers-color-scheme@npm:3.1.1"
+  dependencies:
+    postcss: ^7.0.5
+  bin:
+    css-prefers-color-scheme: cli.js
+  checksum: ba69a86b006818ffe3548bcbeb5e4e8139b8b6cf45815a3b3dddd12cd9acf3d8ac3b94e63fe0abd34e0683cf43ed8c2344e3bd472bbf02a6eb40c7bbf565d587
+  languageName: node
+  linkType: hard
+
+"cssdb@npm:^4.4.0":
+  version: 4.4.0
+  resolution: "cssdb@npm:4.4.0"
+  checksum: 521dd2135da1ab93612a4161eb1024cfc7b155a35d95f9867d328cc88ad57fdd959aa88ea8f4e6cea3a82bca91b76570dc1abb18bfd902c6889973956a03e497
+  languageName: node
+  linkType: hard
+
+"cssesc@npm:^2.0.0":
+  version: 2.0.0
+  resolution: "cssesc@npm:2.0.0"
+  bin:
+    cssesc: bin/cssesc
+  checksum: 5e50886c2aca3f492fe808dbd146d30eb1c6f31fbe6093979a8376e39d171d989279199f6f3f1a42464109e082e0e42bc33eeff9467fb69bf346f5ba5853c3c6
+  languageName: node
+  linkType: hard
+
+"cssesc@npm:^3.0.0":
+  version: 3.0.0
+  resolution: "cssesc@npm:3.0.0"
+  bin:
+    cssesc: bin/cssesc
+  checksum: f8c4ababffbc5e2ddf2fa9957dda1ee4af6048e22aeda1869d0d00843223c1b13ad3f5d88b51caa46c994225eacb636b764eb807a8883e2fb6f99b4f4e8c48b2
+  languageName: node
+  linkType: hard
+
+"electron-to-chromium@npm:^1.3.363":
+  version: 1.3.377
+  resolution: "electron-to-chromium@npm:1.3.377"
+  checksum: 46cb4fe5c28c5277efcbdddea0d9de7935031c822d9adee1f2f5038e4daae8caee3edbc63886fc4d188292096dcd48ddb0ed086341d693ca0fe8fdbd72e8cae5
+  languageName: node
+  linkType: hard
+
+"escape-string-regexp@npm:^1.0.5":
+  version: 1.0.5
+  resolution: "escape-string-regexp@npm:1.0.5"
+  checksum: 6092fda75c63b110c706b6a9bfde8a612ad595b628f0bd2147eea1d3406723020810e591effc7db1da91d80a71a737a313567c5abb3813e8d9c71f4aa595b410
+  languageName: node
+  linkType: hard
+
+"flatten@npm:^1.0.2":
+  version: 1.0.3
+  resolution: "flatten@npm:1.0.3"
+  checksum: 5c57379816f1692aaa79fbc6390e0a0644e5e8442c5783ed57c6d315468eddbc53a659eaa03c9bb1e771b0f4a9bd8dd8a2620286bf21fd6538a7857321fdfb20
+  languageName: node
+  linkType: hard
+
+"has-flag@npm:^3.0.0":
+  version: 3.0.0
+  resolution: "has-flag@npm:3.0.0"
+  checksum: 4a15638b454bf086c8148979aae044dd6e39d63904cd452d970374fa6a87623423da485dfb814e7be882e05c096a7ccf1ebd48e7e7501d0208d8384ff4dea73b
+  languageName: node
+  linkType: hard
+
+"indexes-of@npm:^1.0.1":
+  version: 1.0.1
+  resolution: "indexes-of@npm:1.0.1"
+  checksum: 4f9799b1739a62f3e02d09f6f4162cf9673025282af7fa36e790146e7f4e216dad3e776a25b08536c093209c9fcb5ea7bd04b082d42686a45f58ff401d6da32e
+  languageName: node
+  linkType: hard
+
+"lodash._reinterpolate@npm:^3.0.0":
+  version: 3.0.0
+  resolution: "lodash._reinterpolate@npm:3.0.0"
+  checksum: 06d2d5f33169604fa5e9f27b6067ed9fb85d51a84202a656901e5ffb63b426781a601508466f039c720af111b0c685d12f1a5c14ff8df5d5f27e491e562784b2
+  languageName: node
+  linkType: hard
+
+"lodash.template@npm:^4.5.0":
+  version: 4.5.0
+  resolution: "lodash.template@npm:4.5.0"
+  dependencies:
+    lodash._reinterpolate: ^3.0.0
+    lodash.templatesettings: ^4.0.0
+  checksum: ca64e5f07b6646c9d3dbc0fe3aaa995cb227c4918abd1cef7a9024cd9c924f2fa389a0ec4296aa6634667e029bc81d4bbdb8efbfde11df76d66085e6c529b450
+  languageName: node
+  linkType: hard
+
+"lodash.templatesettings@npm:^4.0.0":
+  version: 4.2.0
+  resolution: "lodash.templatesettings@npm:4.2.0"
+  dependencies:
+    lodash._reinterpolate: ^3.0.0
+  checksum: 863e025478b092997e11a04e9d9e735875eeff1ffcd6c61742aa8272e3c2cddc89ce795eb9726c4e74cef5991f722897ff37df7738a125895f23fc7d12a7bb59
+  languageName: node
+  linkType: hard
+
+"node-releases@npm:^1.1.50":
+  version: 1.1.52
+  resolution: "node-releases@npm:1.1.52"
+  dependencies:
+    semver: ^6.3.0
+  checksum: 7a2fcec1c876925bd4f1b0ab6b92c305e1943385bf49098015f7ba89e7d9b96113994a586fada448242d90192f17f9ff1d37bca271015e41e808cb3d48598bc8
+  languageName: node
+  linkType: hard
+
+"normalize-range@npm:^0.1.2":
+  version: 0.1.2
+  resolution: "normalize-range@npm:0.1.2"
+  checksum: 9b2f14f093593f367a7a0834267c24f3cb3e887a2d9809c77d8a7e5fd08738bcd15af46f0ab01cc3a3d660386f015816b5c922cea8bf2ee79777f40874063184
+  languageName: node
+  linkType: hard
+
+"num2fraction@npm:^1.2.2":
+  version: 1.2.2
+  resolution: "num2fraction@npm:1.2.2"
+  checksum: 1da9c6797b505d3f5b17c7f694c4fa31565bdd5c0e5d669553253aed848a580804cd285280e8a73148bd9628839267daee4967f24b53d4e893e44b563e412635
+  languageName: node
+  linkType: hard
+
+"postcss-attribute-case-insensitive@npm:^4.0.1":
+  version: 4.0.2
+  resolution: "postcss-attribute-case-insensitive@npm:4.0.2"
+  dependencies:
+    postcss: ^7.0.2
+    postcss-selector-parser: ^6.0.2
+  checksum: e9cf4b61f443bf302dcd1110ef38d6a808fa38ae5d85bfd0aaaa6d35bef3825e0434f1aed8eb9596a5d88f21580ce8b9cd0098414d8490293ef71149695cae9a
+  languageName: node
+  linkType: hard
+
+"postcss-color-functional-notation@npm:^2.0.1":
+  version: 2.0.1
+  resolution: "postcss-color-functional-notation@npm:2.0.1"
+  dependencies:
+    postcss: ^7.0.2
+    postcss-values-parser: ^2.0.0
+  checksum: 0bfd1fa93bc54a07240d821d091093256511f70f0df5349e27e4d8b034ee3345f0ae58674ce425be6a91cc934325b2ce36ecddbf958fa8805fed6647cf671348
+  languageName: node
+  linkType: hard
+
+"postcss-color-gray@npm:^5.0.0":
+  version: 5.0.0
+  resolution: "postcss-color-gray@npm:5.0.0"
+  dependencies:
+    "@csstools/convert-colors": ^1.4.0
+    postcss: ^7.0.5
+    postcss-values-parser: ^2.0.0
+  checksum: 81a62b3e2c170ffadc085c1643a7b5f1c153837d7ca228b07df88b9aeb0ec9088a92f8d919a748137ead3936e8dac2606e32b14b5166a59143642c8573949db5
+  languageName: node
+  linkType: hard
+
+"postcss-color-hex-alpha@npm:^5.0.3":
+  version: 5.0.3
+  resolution: "postcss-color-hex-alpha@npm:5.0.3"
+  dependencies:
+    postcss: ^7.0.14
+    postcss-values-parser: ^2.0.1
+  checksum: 0a0ccb42c7c6a271ffd3c8b123b9c67744827d4b810b759731bc702fea1e00f05f08479ec7cbd8dfa47bc20510830a69f1e316a5724b9e53d5fdc6fabf90afc4
+  languageName: node
+  linkType: hard
+
+"postcss-color-mod-function@npm:^3.0.3":
+  version: 3.0.3
+  resolution: "postcss-color-mod-function@npm:3.0.3"
+  dependencies:
+    "@csstools/convert-colors": ^1.4.0
+    postcss: ^7.0.2
+    postcss-values-parser: ^2.0.0
+  checksum: ecbf74e9395527aaf3e83b90b1a6c9bba0a1904038d8acef1f530d50a68d912d6b1af8df690342f942be8b89fa7dfaa35ae67cb5fb48013cb389ecb8c74deadb
+  languageName: node
+  linkType: hard
+
+"postcss-color-rebeccapurple@npm:^4.0.1":
+  version: 4.0.1
+  resolution: "postcss-color-rebeccapurple@npm:4.0.1"
+  dependencies:
+    postcss: ^7.0.2
+    postcss-values-parser: ^2.0.0
+  checksum: a7b1a204dfc5163ac4195cc3cb0c7b1bba9561feab49d24be8a17d695d6b69fd92f3da23d638260fe7e9d5076cf81bb798b25134fa2a2fbf7f74b0dda2829a96
+  languageName: node
+  linkType: hard
+
+"postcss-custom-media@npm:^7.0.8":
+  version: 7.0.8
+  resolution: "postcss-custom-media@npm:7.0.8"
+  dependencies:
+    postcss: ^7.0.14
+  checksum: 3786eb10f238b22dc620cfcc9257779e27d8cee4510b3209d0ab67310e07dc68b69f3359db7a911f5e76df466f73d078fc80100943fe2e8fa9bcacf226705a2d
+  languageName: node
+  linkType: hard
+
+"postcss-custom-properties@npm:^8.0.11":
+  version: 8.0.11
+  resolution: "postcss-custom-properties@npm:8.0.11"
+  dependencies:
+    postcss: ^7.0.17
+    postcss-values-parser: ^2.0.1
+  checksum: cb1b47459a23ff2e48714c5d48d50070d573ef829dc7e57189d1b38c6fba0de7084f1acefbd84c61dd67e30bd9a7d154b22f195547728a9dc5f76f7d3f03ffea
+  languageName: node
+  linkType: hard
+
+"postcss-custom-selectors@npm:^5.1.2":
+  version: 5.1.2
+  resolution: "postcss-custom-selectors@npm:5.1.2"
+  dependencies:
+    postcss: ^7.0.2
+    postcss-selector-parser: ^5.0.0-rc.3
+  checksum: 26c83d348448f4ab5931cc1621606b09a6b1171e25fac2404073f3e298e77494ac87d4a21009679503b4895452810e93e618b5af26b4c7180a9013f283bb8088
+  languageName: node
+  linkType: hard
+
+"postcss-dir-pseudo-class@npm:^5.0.0":
+  version: 5.0.0
+  resolution: "postcss-dir-pseudo-class@npm:5.0.0"
+  dependencies:
+    postcss: ^7.0.2
+    postcss-selector-parser: ^5.0.0-rc.3
+  checksum: 703156fc65f259ec2e86ba51d18370a6d3b71f2e6473c7d65694676a8f0152137b1997bc0a53f7f373c8c3e4d63c72f7b5e2049f2ef3a7276b49409395722044
+  languageName: node
+  linkType: hard
+
+"postcss-double-position-gradients@npm:^1.0.0":
+  version: 1.0.0
+  resolution: "postcss-double-position-gradients@npm:1.0.0"
+  dependencies:
+    postcss: ^7.0.5
+    postcss-values-parser: ^2.0.0
+  checksum: d2c4515b38a131ece44dba331aea2b3f9de646e30873b49f03fa8906179a3c43ddc43183bc4df609d8af0834e7c266ec3a63eaa4b3e96aa445d98ecdc12d2544
+  languageName: node
+  linkType: hard
+
+"postcss-env-function@npm:^2.0.2":
+  version: 2.0.2
+  resolution: "postcss-env-function@npm:2.0.2"
+  dependencies:
+    postcss: ^7.0.2
+    postcss-values-parser: ^2.0.0
+  checksum: 0cfa2e6cad5123cce39dcf5af332ec3b0e3e09b54d5142225f255914079d2afda3f1052e60f4b6d3bccf7eb9d592325b7421f1ecc6674ccb13c267a721fc3128
+  languageName: node
+  linkType: hard
+
+"postcss-focus-visible@npm:^4.0.0":
+  version: 4.0.0
+  resolution: "postcss-focus-visible@npm:4.0.0"
+  dependencies:
+    postcss: ^7.0.2
+  checksum: a3c93fbb578608f60c5256d0989ae32fd9100f76fa053880e82bfeb43751e81a3a9e69bd8338e06579b7f56b230a80fb2cc671eff134f2682dcbec9bbb8658ae
+  languageName: node
+  linkType: hard
+
+"postcss-focus-within@npm:^3.0.0":
+  version: 3.0.0
+  resolution: "postcss-focus-within@npm:3.0.0"
+  dependencies:
+    postcss: ^7.0.2
+  checksum: 2a31292cd9b929a2dd3171fc4ed287ea4a93c6ec8df1d634503fb97b8b30b33a2970b5e0df60634c60ff887923ab28641b624d566533096950e0a384705e9b90
+  languageName: node
+  linkType: hard
+
+"postcss-font-variant@npm:^4.0.0":
+  version: 4.0.0
+  resolution: "postcss-font-variant@npm:4.0.0"
+  dependencies:
+    postcss: ^7.0.2
+  checksum: 47589557b873c23b1cc81630bc627c52cc9653fbc5e15adfd55559f3f556343eecaae726626d92064c8e754f1f45ef6d5fd954bd32ade01427ed7ac8bf10de92
+  languageName: node
+  linkType: hard
+
+"postcss-gap-properties@npm:^2.0.0":
+  version: 2.0.0
+  resolution: "postcss-gap-properties@npm:2.0.0"
+  dependencies:
+    postcss: ^7.0.2
+  checksum: c842d105c9403e34a8fac7bdef33a63fcb6bde038b04b20cae1e719e1966632887545576af99a4a6f302c98ca029c6f0d746419f498ef7f6821177ba676e6c25
+  languageName: node
+  linkType: hard
+
+"postcss-image-set-function@npm:^3.0.1":
+  version: 3.0.1
+  resolution: "postcss-image-set-function@npm:3.0.1"
+  dependencies:
+    postcss: ^7.0.2
+    postcss-values-parser: ^2.0.0
+  checksum: 43958d7c1f80077e60e066bdf61bc326bcac64c272f17fd7a0585a6934fb1ffc7ba7f560a39849f597e4d28b8ae3addd9279c7145b9478d2d91a7c54c2fefd8b
+  languageName: node
+  linkType: hard
+
+"postcss-initial@npm:^3.0.0":
+  version: 3.0.2
+  resolution: "postcss-initial@npm:3.0.2"
+  dependencies:
+    lodash.template: ^4.5.0
+    postcss: ^7.0.2
+  checksum: fe47de21f746c3498b63d2cceaea4e0e3d0dfe8253cfcfd02404e6f5d4d80302d043ae10f215b0206c0ea9ac24125ab7d3500bce24654cb0c42dbb05787209a2
+  languageName: node
+  linkType: hard
+
+"postcss-lab-function@npm:^2.0.1":
+  version: 2.0.1
+  resolution: "postcss-lab-function@npm:2.0.1"
+  dependencies:
+    "@csstools/convert-colors": ^1.4.0
+    postcss: ^7.0.2
+    postcss-values-parser: ^2.0.0
+  checksum: 598229a7a05803b18cccde28114833e910367c5954341bea03c7d7b7b5a667dfb6a77ef9dd4a16d80fdff8b10dd44c478602a7d56e43687c8687af3710b4706f
+  languageName: node
+  linkType: hard
+
+"postcss-logical@npm:^3.0.0":
+  version: 3.0.0
+  resolution: "postcss-logical@npm:3.0.0"
+  dependencies:
+    postcss: ^7.0.2
+  checksum: 5278661b78a093661c9cac8c04666d457734bf156f83d8c67f6034c00e8d4b3a26fce32a8a4a251feae3c7587f42556412dca980e100d0c920ee55e878f7b8ee
+  languageName: node
+  linkType: hard
+
+"postcss-media-minmax@npm:^4.0.0":
+  version: 4.0.0
+  resolution: "postcss-media-minmax@npm:4.0.0"
+  dependencies:
+    postcss: ^7.0.2
+  checksum: 8a4d94e25089bb5a66c6742bcdd263fce2fea391438151a85b442b7f8b66323bbca552b59a93efd6bcabcfd41845ddd4149bd56d156b008f8d7d04bc84d9fb11
+  languageName: node
+  linkType: hard
+
+"postcss-nesting@npm:^7.0.0":
+  version: 7.0.1
+  resolution: "postcss-nesting@npm:7.0.1"
+  dependencies:
+    postcss: ^7.0.2
+  checksum: 4056be95759e8b25477f19aff7202b57dd27eeef41d31f7ca14e4c87d16ffb40e4db3f518fc85bd28b20e183f5e5399b56b52fcc79affd556e13a98bbc678169
+  languageName: node
+  linkType: hard
+
+"postcss-overflow-shorthand@npm:^2.0.0":
+  version: 2.0.0
+  resolution: "postcss-overflow-shorthand@npm:2.0.0"
+  dependencies:
+    postcss: ^7.0.2
+  checksum: 553be1b7f9645017d33b654f9a436ce4f4406066c3056ca4c7ee06c21c2964fbe3437a9a3f998137efb6a17c1a79ee7e8baa39332c7dd9874aac8b69a3ad08b0
+  languageName: node
+  linkType: hard
+
+"postcss-page-break@npm:^2.0.0":
+  version: 2.0.0
+  resolution: "postcss-page-break@npm:2.0.0"
+  dependencies:
+    postcss: ^7.0.2
+  checksum: 65a4453883e904ca0f337d3a988a1b5a090e2e8bc2855913cb0b4b741158e6ea2e4eed9b33f5989e7ae55faa0f7b83cdc09693d600ac4c86ce804ae381ec48a4
+  languageName: node
+  linkType: hard
+
+"postcss-place@npm:^4.0.1":
+  version: 4.0.1
+  resolution: "postcss-place@npm:4.0.1"
+  dependencies:
+    postcss: ^7.0.2
+    postcss-values-parser: ^2.0.0
+  checksum: 26b2a443b0a8fcb6774d00036fa351633798a655ccd609da2d561fbd6561b0ba6f6b6d89e15fb074389fadb7da4cbc59c48ba75f1f5fdc478c020febb4e2b557
+  languageName: node
+  linkType: hard
+
+"postcss-preset-env@npm:^6.7.0":
+  version: 6.7.0
+  resolution: "postcss-preset-env@npm:6.7.0"
+  dependencies:
+    autoprefixer: ^9.6.1
+    browserslist: ^4.6.4
+    caniuse-lite: ^1.0.30000981
+    css-blank-pseudo: ^0.1.4
+    css-has-pseudo: ^0.10.0
+    css-prefers-color-scheme: ^3.1.1
+    cssdb: ^4.4.0
+    postcss: ^7.0.17
+    postcss-attribute-case-insensitive: ^4.0.1
+    postcss-color-functional-notation: ^2.0.1
+    postcss-color-gray: ^5.0.0
+    postcss-color-hex-alpha: ^5.0.3
+    postcss-color-mod-function: ^3.0.3
+    postcss-color-rebeccapurple: ^4.0.1
+    postcss-custom-media: ^7.0.8
+    postcss-custom-properties: ^8.0.11
+    postcss-custom-selectors: ^5.1.2
+    postcss-dir-pseudo-class: ^5.0.0
+    postcss-double-position-gradients: ^1.0.0
+    postcss-env-function: ^2.0.2
+    postcss-focus-visible: ^4.0.0
+    postcss-focus-within: ^3.0.0
+    postcss-font-variant: ^4.0.0
+    postcss-gap-properties: ^2.0.0
+    postcss-image-set-function: ^3.0.1
+    postcss-initial: ^3.0.0
+    postcss-lab-function: ^2.0.1
+    postcss-logical: ^3.0.0
+    postcss-media-minmax: ^4.0.0
+    postcss-nesting: ^7.0.0
+    postcss-overflow-shorthand: ^2.0.0
+    postcss-page-break: ^2.0.0
+    postcss-place: ^4.0.1
+    postcss-pseudo-class-any-link: ^6.0.0
+    postcss-replace-overflow-wrap: ^3.0.0
+    postcss-selector-matches: ^4.0.0
+    postcss-selector-not: ^4.0.0
+  checksum: 209cbb63443a1631aa97ccfc3b95b1ff519ddaeb672f84d6af501bd9e9ad6727680b5b1bffb8209322e47d93029a69df6064f75cd0b7633b6df943cbef33f22e
+  languageName: node
+  linkType: hard
+
+"postcss-pseudo-class-any-link@npm:^6.0.0":
+  version: 6.0.0
+  resolution: "postcss-pseudo-class-any-link@npm:6.0.0"
+  dependencies:
+    postcss: ^7.0.2
+    postcss-selector-parser: ^5.0.0-rc.3
+  checksum: d7dc3bba45df2966f8512c082a9cc341e63edac14d915ad9f41c62c452cd306d82da6baeee757dd4e7deafe3fa33b26c16e5236c670916bbb7ff4b4723453541
+  languageName: node
+  linkType: hard
+
+"postcss-replace-overflow-wrap@npm:^3.0.0":
+  version: 3.0.0
+  resolution: "postcss-replace-overflow-wrap@npm:3.0.0"
+  dependencies:
+    postcss: ^7.0.2
+  checksum: 8c5b512a1172dd3d7b4a06d56d3b64c76dea01ca0950b546f83ae993f83aa95f933239e18deed0a5f3d2ef47840de55fa73498c4a46bfbe7bd892eb0dd8b606c
+  languageName: node
+  linkType: hard
+
+"postcss-selector-matches@npm:^4.0.0":
+  version: 4.0.0
+  resolution: "postcss-selector-matches@npm:4.0.0"
+  dependencies:
+    balanced-match: ^1.0.0
+    postcss: ^7.0.2
+  checksum: 724f6cb345477691909468268a456f978ad3bae9ecd9908b2bb55c55c5f3c6d54a1fe50ce3956d93b122d05fc36677a8e4a34eed07bccda969c3f8baa43669a6
+  languageName: node
+  linkType: hard
+
+"postcss-selector-not@npm:^4.0.0":
+  version: 4.0.0
+  resolution: "postcss-selector-not@npm:4.0.0"
+  dependencies:
+    balanced-match: ^1.0.0
+    postcss: ^7.0.2
+  checksum: f7d1abc3f240fcae4b81e0cbfaf4c2b363a473a66742497a430c786498abd6be0e1ce9e42b43c64877988356f0b8c5e2446e5bcec722bcef807d275a8f596837
+  languageName: node
+  linkType: hard
+
+"postcss-selector-parser@npm:^5.0.0-rc.3, postcss-selector-parser@npm:^5.0.0-rc.4":
+  version: 5.0.0
+  resolution: "postcss-selector-parser@npm:5.0.0"
+  dependencies:
+    cssesc: ^2.0.0
+    indexes-of: ^1.0.1
+    uniq: ^1.0.1
+  checksum: e49d21455e06d2cb9bf2a615bf3e605e0603c2c430a84c37a34f8baedaf3e8f9d0059a085d3e0483cbfa04c0d4153c7da28e7ac0ada319efdefe407df11dc1d4
+  languageName: node
+  linkType: hard
+
+"postcss-selector-parser@npm:^6.0.2":
+  version: 6.0.2
+  resolution: "postcss-selector-parser@npm:6.0.2"
+  dependencies:
+    cssesc: ^3.0.0
+    indexes-of: ^1.0.1
+    uniq: ^1.0.1
+  checksum: 5fa344e63bfeda65720d49669696d243b31dd533095fc7a7f39ef8556f511e1ed91ebbe049ff967b2dfa1ac3d5d452091a09614158c94687e24895411ab3c23e
+  languageName: node
+  linkType: hard
+
+"postcss-value-parser@npm:^4.0.2":
+  version: 4.0.3
+  resolution: "postcss-value-parser@npm:4.0.3"
+  checksum: fbbad3bcbd108d05a5625f268faf1b6f61e7c8eb38cd259b8b57f25cfda3a4f4bebfd3f57a50816db4f9d8d3c6eef52f4e80525915c6761b69a409f07ab3a578
+  languageName: node
+  linkType: hard
+
+"postcss-values-parser@npm:^2.0.0, postcss-values-parser@npm:^2.0.1":
+  version: 2.0.1
+  resolution: "postcss-values-parser@npm:2.0.1"
+  dependencies:
+    flatten: ^1.0.2
+    indexes-of: ^1.0.1
+    uniq: ^1.0.1
+  checksum: 050877880937e15af8d18bf48902e547e2123d7cc32c1f215b392642bc5e2598a87a341995d62f38e450aab4186b8afeb2c9541934806d458ad8b117020b2ebf
+  languageName: node
+  linkType: hard
+
+"postcss@npm:^7.0.14, postcss@npm:^7.0.17, postcss@npm:^7.0.2, postcss@npm:^7.0.26, postcss@npm:^7.0.5, postcss@npm:^7.0.6":
+  version: 7.0.27
+  resolution: "postcss@npm:7.0.27"
+  dependencies:
+    chalk: ^2.4.2
+    source-map: ^0.6.1
+    supports-color: ^6.1.0
+  checksum: 0e2850b58d7ff5a35132dda1ff3863ee0b2377c14b711045511c322429123c71885d572d3c56c4e574b970fa01618a05af86dc5d32a3e7b15901833949f7a2c8
+  languageName: node
+  linkType: hard
+
+"qs@npm:^6.6.0":
+  version: 6.9.1
+  resolution: "qs@npm:6.9.1"
+  checksum: b8ad80e09bb52232963aadd9276b8d3802723c9ecd31388ff129a7ab5542e7dc67c43a05b2250f973be460d2c734f16d8d908216e5340024349763ee5e19666c
+  languageName: node
+  linkType: hard
+
+"root-workspace-0b6124@workspace:.":
+  version: 0.0.0-use.local
+  resolution: "root-workspace-0b6124@workspace:."
+  dependencies:
+    autoprefixer: ^9.7.4
+    postcss-preset-env: ^6.7.0
+    qs: ^6.6.0
+  languageName: unknown
+  linkType: soft
+
+"semver@npm:^6.3.0":
+  version: 6.3.0
+  resolution: "semver@npm:6.3.0"
+  bin:
+    semver: ./bin/semver.js
+  checksum: 1b26ecf6db9e8292dd90df4e781d91875c0dcc1b1909e70f5d12959a23c7eebb8f01ea581c00783bbee72ceeaad9505797c381756326073850dc36ed284b21b9
+  languageName: node
+  linkType: hard
+
+"source-map@npm:^0.6.1":
+  version: 0.6.1
+  resolution: "source-map@npm:0.6.1"
+  checksum: 59ce8640cf3f3124f64ac289012c2b8bd377c238e316fb323ea22fbfe83da07d81e000071d7242cad7a23cd91c7de98e4df8830ec3f133cb6133a5f6e9f67bc2
+  languageName: node
+  linkType: hard
+
+"supports-color@npm:^5.3.0":
+  version: 5.5.0
+  resolution: "supports-color@npm:5.5.0"
+  dependencies:
+    has-flag: ^3.0.0
+  checksum: 95f6f4ba5afdf92f495b5a912d4abee8dcba766ae719b975c56c084f5004845f6f5a5f7769f52d53f40e21952a6d87411bafe34af4a01e65f9926002e38e1dac
+  languageName: node
+  linkType: hard
+
+"supports-color@npm:^6.1.0":
+  version: 6.1.0
+  resolution: "supports-color@npm:6.1.0"
+  dependencies:
+    has-flag: ^3.0.0
+  checksum: 74358f9535c83ee113fbaac354b11e808060f6e7d8722082ee43af3578469134e89d00026dce2a6b93ce4e5b89d0e9a10f638b2b9f64c7838c2fb2883a47b3d5
+  languageName: node
+  linkType: hard
+
+"uniq@npm:^1.0.1":
+  version: 1.0.1
+  resolution: "uniq@npm:1.0.1"
+  checksum: 8206535f83745ea83f9da7035f3b983fd6ed5e35b8ed7745441944e4065b616bc67cf0d0a23a86b40ee0074426f0607f0a138f9b78e124eb6a7a6a6966055709
+  languageName: node
+  linkType: hard
diff --git a/test/update-db.test.js b/test/update-db.test.js
index 33070706..44bf7e7c 100644
--- a/test/update-db.test.js
+++ b/test/update-db.test.js
@@ -69,17 +69,36 @@ function checkRunUpdateNoChanges () {
   )
 }
 
-const yarnLockfileVersions = 'caniuse-lite@^1.0.30000981, ' +
+function checkRunUpdateYarnv2 () {
+  expect(runUpdate()).toContain(
+    `Latest version:     ${ caniuse.version }\n` +
+    'Updating caniuse-lite version\n' +
+    '$ yarn up -R caniuse-lite\n' +
+    'caniuse-lite has been successfully updated\n'
+  )
+}
+
+const yarnLockfile1Versions = 'caniuse-lite@^1.0.30000981, ' +
   'caniuse-lite@^1.0.30001020, caniuse-lite@^1.0.30001030:'
 
-async function checkYarnLockfile (dir) {
+const yarnLockfile2Versions = '"caniuse-lite@npm:^1.0.30000981, ' +
+  'caniuse-lite@npm:^1.0.30001020, caniuse-lite@npm:^1.0.30001030":'
+
+async function checkYarnLockfile (dir, version) {
+  let yarnLockfileVersions = yarnLockfile1Versions
+  let versionSyntax = `  version "${ caniuse.version }"`
+
+  if (version === 2) {
+    yarnLockfileVersions = yarnLockfile2Versions
+    versionSyntax = `  version: ${ caniuse.version }`
+  }
+
   let contents = (await readFile(join(dir, 'yarn.lock'))).toString()
   expect(contents).toContain(
     `${ yarnLockfileVersions }\n`
   )
   expect(contents).toContain(
-    `${ yarnLockfileVersions }\n` +
-    `  version "${ caniuse.version }"`
+    `${ yarnLockfileVersions }\n` + versionSyntax
   )
 }
 
@@ -202,6 +221,16 @@ it('updates caniuse-lite for yarn with workspaces', async () => {
   checkYarnLockfile(dir)
 })
 
+if (!NODE_8 && !NODE_10) {
+  it('updates caniuse-lite for yarn v2', async () => {
+    let dir = await chdir('update-yarn-v2', 'package.json', 'yarn.lock')
+    execSync('yarn set version berry')
+    checkRunUpdateYarnv2()
+    checkYarnLockfile(dir, 2)
+    execSync('yarn set version classic')
+  })
+}
+
 if (!NODE_8 && !NODE_10 && (isInstalled('pnpm') || process.env.CI)) {
   let versions = ['1.0.30001000', '1.0.1234', '1.0.3000', '1.0.30001035']
   it('updates caniuse-lite for pnpm', async () => {