Yarn installing wrong version of jest in workspace

Viewed 244

I have a project with yarn (v1) workspaces.

project/
  packages/
    pkgA/
      subPkgA1/
    pkgB/

package.json has this:

"workspaces": {
  "packages": [
    "packages/pkgA",
    "packages/pkgA/subPkgA1",
    "packages/pkgB"]}

note that there's a nested workspace in there.

  • Top-level has jest@27.4.7 in its package.json.
  • pkgA has jest@24.9.0 because one of its dependencies requires that version; its package.json has no entry for jest.
  • pkgA/subPkgA1 has jest@27.4.7 in its package.json, BUT it actually gets 24.9.0 installed in its node_modules/.bin/jest, presumably because its parent workspace has that.

My main question is how to get jest@27.4.7 in the nested package subPkgA1? I tried adding an entry in pkgA's package.json, but that didn't help.

BTW, I know nested workspaces aren't fully supported until Yarn v2, but I can't upgrade right now, and I can't easily move my subpackage out of its parent, so any hacky solution would be better than nothing.

0 Answers
Related