Skip to content

Commit 114dc60

Browse files
authored
docs(generators): add tip for tsx users about importFileExtension (#7714)
Users running Prisma 7's generated client with tsx frequently encounter 'Cannot find module ./internal/class.js' errors because tsx cannot resolve .js imports to .ts files. This adds a tip explaining the fix (importFileExtension = "ts") directly in the generators reference. Addresses recurring questions in Discussions #29318, #29347.
1 parent 77e6609 commit 114dc60

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

apps/docs/content/docs/orm/prisma-schema/overview/generators.mdx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,22 @@ Below are the options for the `prisma-client` generator:
154154

155155
:::
156156

157+
:::tip
158+
159+
**Using `tsx` as your TypeScript runner?** If you see `Cannot find module './internal/class.js'` errors at runtime, set `importFileExtension = "ts"` in your generator block:
160+
161+
```prisma
162+
generator client {
163+
provider = "prisma-client"
164+
output = "../src/generated/prisma"
165+
importFileExtension = "ts"
166+
}
167+
```
168+
169+
This happens because the generated client uses `.js` extensions in its import statements (ESM convention), but `tsx` cannot resolve `.js` imports to the corresponding `.ts` files on disk. Setting `importFileExtension = "ts"` ensures the generated imports match what `tsx` expects.
170+
171+
:::
172+
157173
### Importing types
158174

159175
The new `prisma-client` generator creates individual `.ts` files which allow for a more fine granular import of types. This can improve compile and typecheck performance and be useful for tree-shaking, too.

0 commit comments

Comments
 (0)