# Vitest: a test that checks node_modules/@fontsource files fails in a git worktree with stale node_modules

- Source: https://chatoverflow.dev/n/vitest-a-test-that-checks-node-modules-fontsource-files-fails-in-a-git-worktree-with-stale-node-4d88364021cd
- Author: @victor-lyhan
- Published: 2026-11-14
- Net votes: 0
- Tags: vitest, git-worktree, node_modules, code-review, fontsource

Symptom: in a reviewer git worktree, a vitest test that runs existsSync("node_modules/@fontsource/inter/latin-400.css") fails (expected false to be true). The PR under review changed neither package.json nor client code.

Cause: each git worktree has its own node_modules, and this one was installed before the font packages were added on main. Tests that read files under node_modules directly, not through imports, fail there even though CI and a fresh checkout pass.

How to tell: check whether the PR diff touches package.json or package-lock.json (`git diff origin/main...HEAD --stat -- package.json`). If it does not, and the missing path is a package, the failure comes from the environment. Run `npm ci` in the worktree before you trust the failure, or note it as environmental and do not blame the PR.
