Skip to content

fix: declare vite-node as a dependency + support React Router 8 / Vite 8 (#261)#262

Merged
AlemTuzlak merged 1 commit into
mainfrom
fix/vite-node-dependency-rr8-vite8
Jun 19, 2026
Merged

fix: declare vite-node as a dependency + support React Router 8 / Vite 8 (#261)#262
AlemTuzlak merged 1 commit into
mainfrom
fix/vite-node-dependency-rr8-vite8

Conversation

@AlemTuzlak

Copy link
Copy Markdown
Contributor

Summary

Fixes #261react-router-devtools failed with Error [ERR_MODULE_NOT_FOUND]: Cannot find package ''vite-node'' after upgrading a project to React Router 8.

Root cause

The Vite plugin imports vite-node at runtime (src/vite/node-server.ts) to execute react-router.config.ts and route files. vite-node is marked external in tsup.config.ts, so it stays a bare import vite-node/... in the published dist/index.js — it must be resolvable at the consumer. But it was declared only as a devDependency.

It worked on React Router 7 purely as a phantom dependency: @react-router/dev@7 declares vite-node as a real dependency, which pnpm hoisted so the devtools could resolve it. @react-router/dev@8 removed vite-node from its dependencies, so the phantom dependency disappeared and resolution broke for any project on RR8.

Changes

  • Move vite-node to dependencies with range ^5.0.0 || ^6.0.0 (vite-node@5 → Vite 7, vite-node@6 → Vite 8). This is the actual fix — it remains external in tsup (correct; it resolves at the consumer).
  • Tidy the vite peer range to >=5.0.0 (was >=5.0.0 || >=6.0.0). The react-router >=7.0.0 peer range already admits v8; both floors now explicitly cover React Router 8 + Vite 8.
  • New example test-apps/react-router-v8-vite/ — a minimal RR8 + Vite 8 framework-mode app that wires the devtools plugin in by package name (not a relative dist/ path) so it exercises the real consumer resolution path, including the vite-node dependency.
  • Single React version across the workspace — RR8 requires react >=19.2.7, and the workspace shares one linked react-router-devtools across all examples. Without a single React version, the devtools'' React subtree (TanStackDevtools) hit an Invalid hook call from a react/react-dom mismatch. Aligned react/react-dom/@types/* to ^19.2.7/^19.2.2 across the examples + docs and pinned react/react-dom via root pnpm.overrides.
  • sherif: ignore the intentionally-divergent v8 example (-p react-router-v8-vite) so the RR7-vs-RR8 / Vite7-vs-Vite8 divergence doesn''t trip the dependency check.
  • Added a changeset (patch).

Verification

  • ✅ New RR8/Vite8 example: react-router dev boots with no vite-node error, page renders (HTTP 200), devtools instrumentation active; build and typecheck pass.
  • ✅ Existing RR7/Vite7 examples (react-router-vite, custom-server) still build & typecheck.
  • react-router-devtools package: typecheck clean, 377 unit tests pass.
  • sherif and biome clean.

Notes

  • The published-package fix is the vite-node dependency move + peer range; the pnpm.overrides and example version bumps are monorepo-dev concerns only (root package.json is private).
  • In the monorepo, the shared devtools resolves vite-node@5, so the v8 example runs vite-node@5''s server against a Vite 8 dev server — verified working. A real single-version RR8 consumer would resolve vite-node@6.

…ite 8 (#261)

The Vite plugin imports `vite-node` at runtime (it is marked `external` in
tsup, so it stays a bare import in the published `dist`), but `vite-node` was
only a devDependency. It resolved on React Router 7 purely as a phantom
dependency of `@react-router/dev@7`, which declared `vite-node` itself. React
Router 8 dropped `vite-node` from its dependencies, so resolution broke with
`Cannot find package 'vite-node'`.

- Move `vite-node` to `dependencies` (`^5.0.0 || ^6.0.0`, covering Vite 7 and 8).
- Tidy the `vite` peer range to `>=5.0.0` (the `react-router` `>=7.0.0` peer
  already admits v8).
- Add a minimal React Router 8 + Vite 8 example (`test-apps/react-router-v8-vite`)
  that wires the devtools plugin in by package name to exercise real consumer
  resolution. Verified: dev server boots cleanly, build and typecheck pass.
- Align react/react-dom across the examples and docs to ^19.2.7 (RR8 floor) and
  pin react/react-dom via root pnpm.overrides so the shared, workspace-linked
  devtools package resolves a single React version (avoids an invalid-hook-call
  from a react/react-dom mismatch).
- Ignore the intentionally-divergent v8 example in the sherif dependency check.
@pkg-pr-new

pkg-pr-new Bot commented Jun 19, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/react-router-devtools@262

commit: 57ea23b

@AlemTuzlak AlemTuzlak merged commit aae92e4 into main Jun 19, 2026
7 checks passed
@AlemTuzlak AlemTuzlak deleted the fix/vite-node-dependency-rr8-vite8 branch June 19, 2026 10:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Cannot find package 'vite-node' after upgrading to React Router v8

1 participant