Skip to content
Latchkey

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.

remix
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

  1. Add a remix typegen (or remix vite:build which emits types) step before tsc.
  2. Ensure remix.env.d.ts is included by tsconfig.json.
  3. Re-run tsc --noEmit after typegen completes.
.github/workflows/ci.yml
- run: npx remix typegen
- run: npx tsc --noEmit

Restore the ambient references

Keep the generated remix.env.d.ts with its triple-slash references and include it in tsconfig.

remix.env.d.ts
/// <reference types="@remix-run/node" />
/// <reference types="@remix-run/react" />

How to prevent it

  • Run typegen (or a full build) before tsc in CI.
  • Keep remix.env.d.ts and its references intact.
  • Include the generated types directory in tsconfig.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →