Skip to content

Commit

Permalink
feat: add troubleshooting section for nuxt prisma module (#6172)
Browse files Browse the repository at this point in the history
  • Loading branch information
ankur-arch authored Aug 2, 2024
1 parent 8144ddb commit eee82b1
Showing 1 changed file with 59 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
<br />
:::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
Expand Down Expand Up @@ -234,6 +240,12 @@ export default prisma

if (process.env.NODE_ENV !== 'production') globalThis.prismaGlobal = prisma
```
<br/>
:::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

Expand Down Expand Up @@ -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.

0 comments on commit eee82b1

Please sign in to comment.