fix: Prisma client module resolution in production Docker builds - #98
Closed
wiktoriavh wants to merge 1 commit into
Closed
fix: Prisma client module resolution in production Docker builds#98wiktoriavh wants to merge 1 commit into
wiktoriavh wants to merge 1 commit into
Conversation
Prisma generate ran before tsconfig.json was available in the Docker build, so the client was emitted with .ts import paths that Node cannot resolve at runtime. Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
importFileExtension = "js"in the Prisma generator so the generated client uses runtime-safe ESM import pathstsconfig.jsoninto the Docker build stage before runningprisma generate, so Prisma can infer the correct module settings during image buildsContext
Production deploys were failing with
ERR_MODULE_NOT_FOUNDfor/app/dist/generated/prisma/internal/class.tsbecauseprisma generateran beforetsconfig.jsonwas available in the Docker build context. Without it, Prisma defaults to.tsimport extensions, which Node cannot resolve after the app is compiled to JavaScript.Test plan
docker compose run --rm migrateanddocker compose up -d botERR_MODULE_NOT_FOUNDMade with Cursor