W
Wasp3w ago
genyus

Broken generator

I'm attempting to configure a third-party generator in my instance. On the first attempt, setting provider = prisma-docs-generator produces the following compilation error:
[ Db ] Environment variables loaded from .env
[ Db ] Prisma schema loaded from ../db/schema.prisma
[ Db !] Error: Generator "prisma-docs-generator" failed:
[ Db !]
[ Db !] /bin/sh: prisma-docs-generator: command not found
[ Db !]
[ Db ] Environment variables loaded from .env
[ Db ] Prisma schema loaded from ../db/schema.prisma
[ Db !] Error: Generator "prisma-docs-generator" failed:
[ Db !]
[ Db !] /bin/sh: prisma-docs-generator: command not found
[ Db !]
Then a bit more digging online led me to try changing it to provide = node node_modules/prisma-docs-generator, but that failed with the following error:
[ Db ] Environment variables loaded from .env
[ Db ] Prisma schema loaded from ../db/schema.prisma
[ Db !] Error: Generator "node node_modules/prisma-docs-generator" failed:
[ Db !]
[ Db !] node:internal/modules/cjs/loader:1249
[ Db !] throw err;
[ Db !] ^
[ Db !] Error: Cannot find module 'web/app/.wasp/out/server/node_modules/prisma-docs-generator'
[ Db !] at Function._resolveFilename (node:internal/modules/cjs/loader:1246:15)
[ Db !] at Function._load (node:internal/modules/cjs/loader:1072:27)
[ Db !] at TracingChannel.traceSync (node:diagnostics_channel:322:14)
[ Db !] at wrapModuleLoad (node:internal/modules/cjs/loader:216:24)
[ Db !] at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:170:5)
[ Db !] at node:internal/main/run_main_module:36:49 {
[ Db !] code: 'MODULE_NOT_FOUND',
[ Db !] requireStack: []
[ Db !] }
[ Db !] Node.js v23.1.0
[ Db ] Environment variables loaded from .env
[ Db ] Prisma schema loaded from ../db/schema.prisma
[ Db !] Error: Generator "node node_modules/prisma-docs-generator" failed:
[ Db !]
[ Db !] node:internal/modules/cjs/loader:1249
[ Db !] throw err;
[ Db !] ^
[ Db !] Error: Cannot find module 'web/app/.wasp/out/server/node_modules/prisma-docs-generator'
[ Db !] at Function._resolveFilename (node:internal/modules/cjs/loader:1246:15)
[ Db !] at Function._load (node:internal/modules/cjs/loader:1072:27)
[ Db !] at TracingChannel.traceSync (node:diagnostics_channel:322:14)
[ Db !] at wrapModuleLoad (node:internal/modules/cjs/loader:216:24)
[ Db !] at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:170:5)
[ Db !] at node:internal/main/run_main_module:36:49 {
[ Db !] code: 'MODULE_NOT_FOUND',
[ Db !] requireStack: []
[ Db !] }
[ Db !] Node.js v23.1.0
What is the correct way to include additional generators?
10 Replies
kapa.ai
kapa.ai3w ago
Hi @genyus. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Based on the knowledge sources provided, I don't have specific information about configuring third-party generators in Wasp or the correct way to include additional generators. The documents mainly discuss Prisma-related issues and Wasp's internal structure, but they don't directly address your question about adding custom generators. However, I can provide some general insights based on the errors you're encountering: 1. The first error suggests that the prisma-docs-generator is not installed or not in your PATH. This is typically resolved by installing the generator package. 2. The second error indicates that Wasp is looking for the generator in a specific location within its generated structure (web/app/.wasp/out/server/node_modules/prisma-docs-generator), but it's not finding it there. Given Wasp's unique structure and how it manages dependencies, the standard approach for adding Prisma generators might not work directly. Wasp seems to have its own way of handling Prisma and its related packages. To get a definitive answer on how to correctly include additional generators in Wasp, I would recommend: 1. Checking the official Wasp documentation for any information on custom Prisma generators. 2. If not found in the docs, reaching out to the Wasp community or maintainers directly through their GitHub issues or Discord channel for guidance. I apologize that I couldn't provide a more concrete solution based on the available knowledge sources. The correct approach might require specific knowledge about Wasp's internal workings and its integration with Prisma, which isn't covered in the provided documents. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @genyus, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
genyus
genyusOP3w ago
Ok, I understand the problem now, but I’m not sure how to resolve it. I realise that the first configuration fails because the generator isn’t on the path, and it’s being run as a command. The second configuration fails because the server is looking inside its local node_modules directory (which I assume must be generated by Wasp), not the node_modules directory in the project. Having the definition present in schema.prisma breaks compilation, but I can run it manually using npx prisma generate. How can I install/configure it so that the generator is visible to the server? Can anyone from @Wasp Team point me in the right direction?
MEE6
MEE63w ago
Wohooo @genyus, you just became a Waspeteer level 1!
martinsos
martinsos3w ago
I think you correctly identified what happens -> prisma-docs-generator gets installed in top level node_modules, not in the one in .wasp/out/server, and prisma commands run in the context of ./wasp/out/server, so it doesn't find it there. What if you did provider = "npx prisma-docs-generator", would that work? Alternatively, you could also try provider = "node ../../../node_modules/prisma-docs-generator", although npx sounds better since it will do this work of climbing up and finding a package for you. @Filip you might find this interesting.
genyus
genyusOP2w ago
Thanks for following up and apologies for the late response. Just to close this off — I ended up finding another approach to resolve my issue which meant I didn't need to use the actual generator I was trying to incorporate. However, unless I've missed some mechanism to modify the server package configuration, my experimenting appears to suggest that many Prisma generators won't be compatible with Wasp, which is a shame.
Filip
Filip2w ago
Yeah, sounds right. We tried to move it into the project dir for 0.12.0 (restructuring), but then had to revert it because of env vars. I created a new issue to track this: https://github.com/wasp-lang/wasp/issues/2404
genyus
genyusOP2w ago
That's good to know, thanks for the update
martinsos
martinsos2w ago
@genyus thanks for letting us know! Did you however try using npx prisma-docs-generator, did that work?
genyus
genyusOP2w ago
So for this particular generator, npx prisma-docs-generator doesn't work as it executes a different action to running node against the package directory. It does, however, work using the full path as you provided:
generator prisma_docs_generator {
provider = "node ../../../node_modules/prisma-docs-generator"
output = "../../../docs/db"
}
generator prisma_docs_generator {
provider = "node ../../../node_modules/prisma-docs-generator"
output = "../../../docs/db"
}
martinsos
martinsos6d ago
@genyus ok thanks for letting us know!
Want results from more Discord servers?
Add your server