question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
sheremet-vacommented, Aug 3, 2022

Experienced similar issue in a SolidJS project maintained with pnpm. Tests worked flawlessly with 0.19.x and started failing with a cryptic You appear to have multiple instances of Solid. This can lead to unexpected behavior. in 0.20.x. Workaround to disable deps.registerNodeLoader also works in this scenario.

@manoldonev Solid example was updated, you no longer need to inline solid. You can join discord to see updates.

1reaction
sheremet-vacommented, Aug 2, 2022

It’s not possible to use custom experimental loader with Yarn PnP at the moment. We need https://github.com/nodejs/node/pull/43772 to be resolved first.

For now we will detect, if running under Yarn PnP and disable registerNodeLoader in #1773.

Read more comments on GitHub >

github_iconTop Results From Across the Web

utils.ensurePackageInstalled is not compatible with yarn PnP
Describe the bug Trying to run vitest in a package of a yarn monorepo will cause the following error: MISSING DEP Can not...
Read more >
Plug'n'Play | Yarn - Package Manager
An overview of Plug'n'Play, a powerful and innovative installation strategy for Node.
Read more >
Yarn 3.1, Vite 2.9, cannot find package vite - Stack Overflow
If I understand it correctly there seems to be an issue with Yarn PnP resolving dependencies (no more node_modules ), and Vite does...
Read more >
Getting Started | Guide - Vitest
Vitest is a blazing fast unit test framework powered by Vite. You can learn more about the rationale behind the project in the...
Read more >
Benchmarks of JavaScript Package Managers - PNPM
clean install : How long it takes to run a totally fresh install: no ... action, cache, lockfile, node_modules, npm, pnpm, Yarn, Yarn...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found