prisma generate for .mjs
Hi,
Currently I want to generate with .mjs file but when I run
npx prisma generate I getg this error
Here's my schema.prisma file
2 Replies
You've gone full bot mode! Let me fetch that AI answer for you ASAP.
The error you’re seeing is because the Prisma Client generator does not currently support "mjs" as a value for generatedFileExtension. According to the official Prisma documentation, the allowed values for generatedFileExtension are "ts", "mts", and "cts"—not "js", "mjs", or "cjs". Setting it to "mjs" will result in the error you encountered:
Generated file extension "mjs" is unexpected and may be a mistake. Expected one of: "ts", "mts", "cts"To generate ESM-compatible output, you should use "mts" (for TypeScript ESM) or "ts" (for standard TypeScript). If you specifically need JavaScript ESM output, Prisma does not currently support generating ".mjs" files directly. You would need to transpile the generated TypeScript files to ".mjs" using a separate build step (e.g., with TypeScript or Babel). Here’s a corrected generator block for ESM TypeScript output: If you need ".mjs" files, you must handle the conversion after generation. Prisma does not natively support "mjs" as a generated file extension at this time, and attempting to use it will result in the error you described. For more details, see the Prisma generator field reference and related discussions in the issue tracker here. 🤔 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.
Error: Cannot read properties of undefined (reading 'filter')
My bad. I've fixed it by myself