Remix typegen / remix.env.d.ts missing types in CI
Remix generates ambient and route types (referenced via remix.env.d.ts and the .remix typegen output) that tsc needs to type-check loaders, actions, and useLoaderData. If typegen has not run on the runner, the type-check step fails with missing globals or module types.
What this error means
A tsc --noEmit step fails with "Cannot find type definition" or errors on @remix-run/* globals and generated route modules that exist locally but not in CI.
error TS2688: Cannot find type definition file for '@remix-run/node'.
error TS2307: Cannot find module '@remix-run/dev/server-build'.Common causes
Typegen never ran on the runner
The generated types are not committed (and should not be); if CI type-checks without running typegen first, the ambient types are absent.
A stale or missing remix.env.d.ts reference
The remix.env.d.ts triple-slash references are removed or the file is not included by tsconfig, so the ambient declarations never load.
How to fix it
Run typegen before the type-check
- Add a
remix typegen(orremix vite:buildwhich emits types) step beforetsc. - Ensure
remix.env.d.tsis included bytsconfig.json. - Re-run
tsc --noEmitafter typegen completes.
- run: npx remix typegen
- run: npx tsc --noEmitRestore the ambient references
Keep the generated remix.env.d.ts with its triple-slash references and include it in tsconfig.
/// <reference types="@remix-run/node" />
/// <reference types="@remix-run/react" />How to prevent it
- Run typegen (or a full build) before
tscin CI. - Keep
remix.env.d.tsand its references intact. - Include the generated types directory in tsconfig.