diff --git a/content/200-orm/800-more/600-help-and-troubleshooting/100-help-articles/900-prisma-nuxt-module.mdx b/content/200-orm/800-more/600-help-and-troubleshooting/100-help-articles/900-prisma-nuxt-module.mdx index 491addf406..0820bdae57 100644 --- a/content/200-orm/800-more/600-help-and-troubleshooting/100-help-articles/900-prisma-nuxt-module.mdx +++ b/content/200-orm/800-more/600-help-and-troubleshooting/100-help-articles/900-prisma-nuxt-module.mdx @@ -31,6 +31,12 @@ This module provides several features to streamline the setup and usage of Prism cd test-nuxt-app npx nuxi@latest module add @prisma/nuxt ``` +
+ :::warning + + If you're using `pnpm`, make sure to hoist Prisma dependencies. Follow the steps [here](/orm/more/help-and-troubleshooting/help-articles/prisma-nuxt-module#prisma-studio-not-opening-with-pnpm) for detailed instructions. + + ::: 3. Start the development server: ```terminal @@ -234,6 +240,12 @@ export default prisma if (process.env.NODE_ENV !== 'production') globalThis.prismaGlobal = prisma ``` +
+:::info + +Use the `prisma` instance from the `lib` folder if you want to leverage a client using [Prisma Client extensions](/orm/prisma-client/client-extensions). + +::: #### Using the global Prisma Client instance in your API route @@ -297,3 +309,50 @@ The `usePrismaClient` module does not currently allow for configuration of `Pris ### The `usePrismaClient` composable is not supported in edge runtimes The `usePrismaClient` composable currently relies on a `PrismaClient` instance that does not work in edge runtimes. If you require edge support for the composable, please let us know on [Discord](https://pris.ly/discord) or [GitHub](https://github.com/prisma/nuxt-prisma). + +## Troubleshooting + +### Prisma Studio not opening with `pnpm` + +If you're encountering the following error when using `pnpm` and Prisma Studio isn't opening: + +```terminal +Uncaught SyntaxError: The requested module '/_nuxt/node_modules/.pnpm/*@*/node_modules/@prisma/client/index-browser.js?v=' does not provide an export named 'PrismaClient' (at plugin.mjs?v=*) +``` + +To resolve this issue, create a `.npmrc` file in your project root and add the following configuration to hoist Prisma dependencies: + +```.npmrc file=.npmrc +hoist-pattern[]=*prisma* +``` + +This will ensure that Prisma dependencies are properly resolved by `pnpm`. + +### Resolving `TypeError: Failed to resolve module specifier ".prisma/client/index-browser"` + +If you encounter the following error message in the browser console after building and previewing your application: + +``` +TypeError: Failed to resolve module specifier ".prisma/client/index-browser" +``` +To resolve this issue, add the following configuration to your nuxt.config.ts file: + +```ts file=nuxt.config.ts +import { defineNuxtConfig } from 'nuxt' + +export default defineNuxtConfig({ + modules: [ + '@prisma/nuxt', + ], + // additional config + vite: { + resolve: { + alias: { + '.prisma/client/index-browser': './node_modules/.prisma/client/index-browser.js', + }, + }, + }, +}) +``` + +This configuration ensures that the module specifier is correctly mapped to the appropriate file. \ No newline at end of file