[0.20.x] vitest no longer works with yarn pnp
See original GitHub issueDescribe 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
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn’t already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Issue Analytics
- State:
- Created a year ago
- Comments:5 (4 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@manoldonev Solid example was updated, you no longer need to inline solid. You can join discord to see updates.
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.