ERROR Nuxt Build Error: [commonjs--resolver] Invalid module ".prisma/client/index-browser" is not a
Hi i'm using Nuxt 4 + Prisma and i'm trying to build it but I encountered this error during the process.
Here are the versions i'm currently using:
"@prisma/client": "^6.14.0",
"@prisma/nuxt": "^0.3.0",
2 Replies
Hi @MarquiPaul. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
The error you are encountering,
Nuxt 4 sometimes requires you to explicitly transpile certain dependencies that are not fully ESM-compatible. This is especially true for libraries that have both CommonJS and ESM builds, or that use dynamic imports. You can add problematic libraries to the
If you are importing Prisma in a way that causes issues with default exports, you may need to adjust your import statements or use utilities like
The knowledge sources do not mention any specific incompatibility between Nuxt 4 and the versions of
Try adding
[commonjs--resolver] Invalid module ".prisma/client/index-browser"
, when building a Nuxt 4 project with Prisma, is not directly addressed in the provided knowledge sources. However, there are some relevant troubleshooting steps and context that may help:
1. Transpiling Dependencies:Nuxt 4 sometimes requires you to explicitly transpile certain dependencies that are not fully ESM-compatible. This is especially true for libraries that have both CommonJS and ESM builds, or that use dynamic imports. You can add problematic libraries to the
build.transpile
array in your nuxt.config.ts
:
This approach is recommended for libraries that cause ESM/CJS interop issues during build or dev, as described in the Nuxt documentation and related issues Docs: Troubleshooting ESM Issues and Nuxt upgrade causing plugin errors.
2. ESM/CJS Interop:If you are importing Prisma in a way that causes issues with default exports, you may need to adjust your import statements or use utilities like
interopDefault
from mlly
as described in the Nuxt docs. However, this is more relevant for runtime errors than build-time module resolution errors.
3. Prisma and Nuxt Compatibility:The knowledge sources do not mention any specific incompatibility between Nuxt 4 and the versions of
@prisma/client
and @prisma/nuxt
you are using. However, if the error persists after transpiling, it may be related to a bug or incompatibility in the Prisma or Nuxt integration that is not documented in the provided sources.
Summary:Try adding
@prisma/client
to your build.transpile
array in nuxt.config.ts
. If the issue persists, the knowledge sources do not provide a definitive solution, and you may need to consult the latest Nuxt or Prisma documentation or open an issue on their respective repositories.
I'm sorry, but the knowledge sources do not contain a specific solution for this exact error with Nuxt 4 and Prisma.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@699130829938360353> Kapa.ai is still learning and improving, please let me know how I did by reacting below.