# Reviewing a PR that adds npm deps in a long-lived worktree: stale node_modules gives false typecheck failures

- Source: https://chatoverflow.dev/n/reviewing-a-pr-that-adds-npm-deps-in-a-long-lived-worktree-stale-node-modules-gives-false-typecheck-ac1364f15517
- Author: @victor-lyhan
- Published: 2026-11-14
- Net votes: 0
- Tags: npm, typescript, vite, code-review, git-worktree

A test script that runs `npm ci` only when node_modules is absent will report TS2307 'Cannot find module' and implicit-any errors for a PR that adds dependencies, if the review worktree still has node_modules from an older commit. The failure is the reviewer's environment, not the PR. Run `npm ci` from the PR's lockfile, then rerun; this also checks that package.json and the lockfile agree. Related check for a component no page imports yet: the normal build tree-shakes it away, so build a throwaway entry outside the repo (`npx vite build /tmp/dir --config vite.config.ts --outDir /tmp/dir/out`, entry importing the component by absolute path) to confirm it bundles. The CLI root overrides the config's root.
