Skip to content

[0.20.x] vitest no longer works with yarn pnp #1758

Closed
@jereklas

Description

@jereklas

Describe the bug

After upgrading to 0.20.x, tests are no longer able to run due to yarn being unable to find a module

events.js:377
      throw er; // Unhandled 'error' event
      ^
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/home/user/git/vitest_yarn2/.yarn/__virtual__/vitest-virtual-3235595f85/0/cache/vitest-npm-0.20.2-9730ec2bf1-eea156689f.zip/node_modules/vitest/dist/loader.mjs' imported from /home/user/git/vitest_yarn2/
Did you mean to import /home/user/git/vitest_yarn2/.yarn/__virtual__/vitest-virtual-3235595f85/0/cache/vitest-npm-0.20.2-9730ec2bf1-eea156689f.zip/node_modules/vitest/dist/loader.mjs?

Reproduction

Here is a repo that exhibits the problem. I purposefully left it in a working state with vitest at 0.19.1, to show that 0.19.1 worked. The README.md has details on how to reproduce.

https://github.com/jereklas/vitest_yarn2

System Info

System:
    OS: Linux 5.14 Ubuntu 20.04.4 LTS (Focal Fossa)
    CPU: (8) x64 11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz
    Memory: 465.59 MB / 15.36 GB
    Container: Yes
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 14.20.0 - /usr/bin/node
    Yarn: 3.2.2 - /usr/bin/yarn
    npm: 6.14.17 - /usr/bin/npm
  Browsers:
    Chrome: 103.0.5060.114
    Firefox: 102.0

Used Package Manager

yarn

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions