P
Prisma2d ago
mish

Wrong path for finding generated TS queryCompiler

I have prisma in a package in my monorepo. So in backend/ I have all the prisma setup. In backend/prisma/schema.prisma I have my schema:
generator client {
provider = "prisma-client-js"
previewFeatures = ["fullTextSearchPostgres", "postgresqlExtensions", "queryCompiler", "driverAdapters"]
output = "../src/prisma"
}
generator client {
provider = "prisma-client-js"
previewFeatures = ["fullTextSearchPostgres", "postgresqlExtensions", "queryCompiler", "driverAdapters"]
output = "../src/prisma"
}
So it spits the client out in backend/src/prisma which is great When I run my app (I'm using SST for local lambda dev) I get: ENOENT: no such file or directory, open '/home/me/project/src/prisma/query_compiler_bg.wasm' But that should be backend/src/prisma not src/prisma So I'm not clear how to use this generator output in a monorepo
2 Replies
Prisma AI Help
You chose to compile with the bot. One moment while I piece together your answer… This issue is related to how Prisma tries to locate the schema file when using a custom output path in a monorepo setup. The problem you're experiencing is a known issue with Prisma's path resolution mechanism. When you specify a custom output path in your schema.prisma file, Prisma generates the client in that location, but at runtime, it may still look for certain files (like the WASM file) in incorrect locations. This happens because Prisma's internal path resolution logic sometimes struggles with monorepo setups. Based on the knowledge sources, there are several workarounds you could try: 1. Use environment variables to set the output path:
generator client {
provider = "prisma-client-js"
output = env("PRISMA_OUT")
}

generator client {
provider = "prisma-client-js"
output = env("PRISMA_OUT")
}

Then set PRISMA_OUT to the absolute path before generating the client Link to GitHub issue. 2. Generate the client directly into node_modules:
generator client {
provider = "prisma-client-js"
output = "../../../node_modules/@your-scope/prisma-client"
}

generator client {
provider = "prisma-client-js"
output = "../../../node_modules/@your-scope/prisma-client"
}

Then import from that package name Link to GitHub issue. 3. Multiple generator blocks for different output locations if you need the client in multiple places Link to GitHub issue. 4. Copy the schema.prisma file to the location where Prisma is looking for it (though this is more of a hack than a proper solution). The issue seems to be that Prisma is looking for files relative to the project root rather than relative to where the client was generated. This is a known limitation with custom output paths, especially in monorepo setups. If these workarounds don't solve your issue, you might need to open a new issue on the Prisma GitHub repository with a minimal reproduction of your specific setup. I'm limited in providing a definitive solution as the knowledge so urces don't address your exact scenario with the WASM file for query compiler, but these approaches have helped others with similar path resolution issues. 🤔 Alright, thanks for letting us know that there's still some help needed. A team member will reply to you shortly. In the meantime, please let us know any additional info, questions, or which parts of the answer may need clarification.
mish
mishOP2d ago
I'm using 6.7.0 also unrelated I get a TS compile error
RangeError: Maximum call stack size exceeded
at instantiateSignatures (/Users/cyber/dev/tombo/node_modules/.pnpm/[email protected]/node_modules/typescript/lib/_tsc.js:62330:33)
at resolveObjectTypeMembers (/Users/cyber/dev/tombo/node_modules/.pnpm/[email protected]/node_modules/typescript/lib/_tsc.js:56824:24)
at resolveTypeReferenceMembers (/Users/cyber/dev/tombo/node_modules/.pnpm/[email protected]/node_modules/typescript/lib/_tsc.js:56859:5)
RangeError: Maximum call stack size exceeded
at instantiateSignatures (/Users/cyber/dev/tombo/node_modules/.pnpm/[email protected]/node_modules/typescript/lib/_tsc.js:62330:33)
at resolveObjectTypeMembers (/Users/cyber/dev/tombo/node_modules/.pnpm/[email protected]/node_modules/typescript/lib/_tsc.js:56824:24)
at resolveTypeReferenceMembers (/Users/cyber/dev/tombo/node_modules/.pnpm/[email protected]/node_modules/typescript/lib/_tsc.js:56859:5)

Did you find this page helpful?