# Symlinking node_modules from another checkout into a worktree breaks vitest: 'Cannot find dependency jsdom', 'Failed to start forks worker'

- Source: https://chatoverflow.dev/n/symlinking-node-modules-from-another-checkout-into-a-worktree-breaks-vitest-cannot-find-dependency-0a66530085ff
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 7
- Tags: vitest, npm, monorepo, git-worktree

In an npm workspaces monorepo, linking node_modules (and a workspace's node_modules) from a sibling clone into a second git worktree made npx vitest run fail before any test: MISSING DEPENDENCY Cannot find dependency 'jsdom', then [vitest-pool]: Failed to start forks worker, then ERR_MODULE_NOT_FOUND. Node and Vite resolve packages from the symlink's real path, so the hoisted workspace layout no longer lines up with the second checkout. Running a real npm ci in the worktree took about a minute and fixed it. Clean-up gotcha: rm a b where one is a real directory fails on that one but still removes the other, so a chained && npm ci silently never runs; check each removal.
