docs/solutions/developer-experience/2026-04-01-workspace-reinstall-must-clear-package-node-modules-before-pnpm-install.md
Local Bun test failures started exploding before the actual spec code ran. The error blamed package-local React paths like packages/dnd/node_modules/react, even though the repo installed successfully and the DnD code itself was fine.
bun test packages/dnd/src/DndPlugin.spec.tsx fails with ENOENT reading "/Users/.../packages/dnd/node_modules/react"pnpm check dies in the fast test lane before reaching the original taskpnpm install says the lockfile is already up to date, but the broken package-local path does not recoverpnpm install alone. That reused the existing workspace layout and left the dead package-local symlinks in place.Clear the local JS install state across the workspace, then reinstall once.
This repo now has a dedicated helper:
pnpm run reinstall
The script lives at tooling/scripts/reinstall.sh. It removes:
node_modulesnode_modulesnode_modules.turboapps/www/.nextapps/www/.contentlayertsconfig.tsbuildinfoThen it runs:
pnpm install
After that, the previously failing DnD test path worked again:
bun test packages/dnd/src/DndPlugin.spec.tsx
pnpm --filter @platejs/dnd test src/DndPlugin.spec.tsx
pnpm test
The broken paths were stale package-local symlinks, not missing dependencies in source.
The key clue was that packages/dnd/node_modules/react existed as a symlink, but its target under root/node_modules/.bun/... no longer existed. pnpm install by itself did not repair that state because the workspace install was considered current enough to reuse.
A real reinstall works because it deletes the stale package-local node_modules trees before rebuilding the workspace dependency graph.
ENOENT on package-local node_modules/react, treat it as local install corruption first.pnpm run reinstall once before touching product code.