vitest-dev / vitest-dev/vitest

Using 'home' as vite base breaks vitest on linux filesystems

Open
#7,073 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

p3-minor-bug
Dominant language
TypeScript
Stars
17.1k
Forks
2k
Avg merge
1d 22h
Merged PRs (30d)
94

Description

Describe the bug

If you configure vite with

base: 'home',
test: {
  //
},

...

and run "vitest" on any linux file systems, you get the following error:

Error: Failed to load url /projects/vitest-dev-vitest-98qlmqvh/node_modules/vitest/dist/spy.js (resolved id: /projects/vitest-dev-vitest-98qlmqvh/node_modules/vitest/dist/spy.js). Does the file exist?
 ❯ loadAndTransform node_modules/vite/dist/node/chunks/dep-CB_7IfJ-.js:51969:17
 ❯ ViteNodeServer._transformRequest node_modules/vite-node/dist/server.mjs:561:16
 ❯ ViteNodeServer._fetchModule node_modules/vite-node/dist/server.mjs:523:17
 ❯ Proxy.fetch node_modules/vitest/dist/chunks/resolveConfig.RxKrDli4.js:6647:22
 ❯ EventEmitter.onMessage node_modules/vitest/dist/chunks/index.68735LiX.js:104:20

This bug is not reproducible on macOS or Windows and occurs on both npm and pnpm. Configuring the base as '/home/' or '/home' has the same effect.

Reproduction (StackBlitz uses Linux)

https://stackblitz.com/edit/vitest-dev-vitest-98qlmqvh?file=vite.config.ts

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the StackBlitz reproduction and the vite.config.ts configuration using base: 'home'; run Vitest on a Linux filesystem and trace the failed module resolution shown in the error. Compare behavior with '/home/' and '/home', then add coverage for the regression and confirm Vitest loads its module successfully without changing the macOS or Windows behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
linux, typescript, vite
Domain
testing-qa, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.