Keep Node built-in code out of client chunks
Run this rule
Enable the Vite Doctor plugin and rerun your Vite 8+ client build (vite build). This rule needs Build Evidence from the plugin; the standalone CLI cannot verify it.
For watch builds, enable build.sourcemap (for example, "hidden") so the rule can trace the rendered code.
Why it matters
Vite can replace Node built-ins in a client environment with a browser stub instead of failing the build. On Rolldown (Vite 8+), Doctor uses Vite's resolution and final source maps to trace surviving static import bindings and split dynamic imports in JavaScript and TypeScript back to the exact Node import. It skips reads it cannot trace, including branches removed by tree shaking, and does not attribute a package's browser: false mapping to an unrelated Node import. The import chain comes from Vite's module graph; when it has no path from an entry, the Diagnostic says the evidence is partial. The CLI Surface has no Build Evidence.
Recommended fix
Import the module only from server entries or server routes. Move the values the client needs into a module that imports no Node built-in, or load the server code behind an import.meta.env.SSR branch with a dynamic import() so the client build drops it.
Useful links
Example
Keep server-only helpers out of client imports
Before
// src/db.ts
import { readFileSync } from 'node:fs'
export const loadUsers = () => JSON.parse(readFileSync('users.json', 'utf8'))
// src/main.ts (client entry)
import { loadUsers } from './db'
render(loadUsers())
After
// src/server.ts (server entry)
import { loadUsers } from './db'
export const users = loadUsers()
// src/main.ts (client entry)
const users = await fetch('/api/users').then((response) => response.json())
render(users)