Skip to content

ReferenceError: prisma is not defined #32

@chriscreber

Description

@chriscreber

My app works fine locally and is able to pull data through the data proxy, but when I deploy I get this error.

[31mERR�[0m ReferenceError: prisma is not defined
    at resolve (/var/task/.next/server/pages/api/graphql.js:154:68)
    at file:///var/task/node_modules/@pothos/plugin-prisma/esm/field-builder.js:72:37
    at resolvePrismaCursorConnection (file:///var/task/node_modules/@pothos/plugin-prisma/esm/util/cursors.js:234:27)
    at resolve (file:///var/task/node_modules/@pothos/plugin-prisma/esm/field-builder.js:54:51)
    at executeField (file:///var/task/node_modules/@graphql-tools/executor/esm/execution/execute.js:294:24)
    at executeFields (file:///var/task/node_modules/@graphql-tools/executor/esm/execution/execute.js:241:28)
    at executeOperation (file:///var/task/node_modules/@graphql-tools/executor/esm/execution/execute.js:205:18)
    at file:///var/task/node_modules/@graphql-tools/executor/esm/execution/execute.js:62:37
    at new ValueOrPromise (/var/task/node_modules/value-or-promise/build/main/ValueOrPromise.js:14:21)
    at executeImpl (file:///var/task/node_modules/@graphql-tools/executor/esm/execution/execute.js:62:12) {
  path: [ 'links' ],
  locations: [ { line: 2, column: 3 } ],
  extensions: [Object: null prototype] {}
}

I have "vercel-build": "npx prisma generate --data-proxy && next build", in the scripts in package.json. And I can see prisma is getting generated in the deployment logs on Vercel:

Running build in Cleveland, USA (East) – cle1
--
19:52:47.943 | Cloning github.com/chriscreber/awesome-links-done (Branch: main, Commit: 12a8d69)
19:52:48.254 | Cloning completed: 310.432ms
19:52:51.502 | Restored build cache
19:52:51.533 | Running "vercel build"
19:52:52.046 | Vercel CLI 29.3.6
19:52:52.305 | Installing dependencies...
19:52:52.592 | yarn install v1.22.17
19:52:52.622 | info No lockfile found.
19:52:52.627 | [1/4] Resolving packages...
19:52:57.424 | warning aws-sdk > querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
19:52:57.425 | warning aws-sdk > url > querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
19:53:03.700 | [2/4] Fetching packages...
19:53:18.994 | [3/4] Linking dependencies...
19:53:18.997 | warning "graphql-yoga > @envelop/validation-cache@5.1.3" has incorrect peer dependency "@envelop/core@^3.0.6".
19:53:18.998 | warning "graphql-yoga > @envelop/parser-cache@5.0.6" has incorrect peer dependency "@envelop/core@^3.0.6".
19:53:18.998 | warning "react-hot-toast > goober@2.1.13" has unmet peer dependency "csstype@^3.0.10".
19:53:31.896 | [4/4] Building fresh packages...
19:53:32.929 | success Saved lockfile.
19:53:32.932 | $ npx prisma generate --data-proxy
19:53:33.755 | Prisma schema loaded from prisma/schema.prisma
19:53:34.393 |  
19:53:34.394 | ✔ Generated Prisma Client (4.15.0 \| dataproxy) to ./node_modules/@prisma/client in 171ms
19:53:34.394 |  
19:53:34.394 | ✔ Generated Pothos integration to ./node_modules/@pothos/plugin-prisma/generated.ts in 18ms
19:53:34.394 | You can now start using Prisma Client in your code. Reference: https://pris.ly/d/client
19:53:34.394 | ```
19:53:34.394 | import { PrismaClient } from '@prisma/client'
19:53:34.395 | const prisma = new PrismaClient()
19:53:34.395 | ```
19:53:34.395 |  
19:53:34.395 | To use Prisma Client in edge runtimes like Cloudflare Workers or Vercel Edge Functions, import it like this:
19:53:34.395 | ```
19:53:34.396 | import { PrismaClient } from '@prisma/client/edge'
19:53:34.396 | ```
19:53:34.396 |  
19:53:34.397 | You will need a Prisma Data Proxy connection string. See documentation: https://pris.ly/d/data-proxy
19:53:34.397 |  
19:53:34.457 | Done in 41.87s.
19:53:34.498 | Detected Next.js version: 13.4.4
19:53:34.499 | Running "yarn run build"
19:53:34.700 | yarn run v1.22.17
19:53:34.732 | $ next build
19:53:35.247 | - info Linting and checking validity of types...
19:53:45.170 | - info Creating an optimized production build...
19:53:54.943 | - info Compiled successfully
19:53:54.950 | - info Collecting page data...
19:53:55.485 | in prisma file
19:53:55.485 | production
19:53:55.485 | 1
19:53:55.485 | 2
19:53:55.490 | 3
19:53:55.490 | 4
19:54:07.122 | - info Generating static pages (0/5)
19:54:07.194 | - info Generating static pages (1/5)
19:54:07.206 | - info Generating static pages (2/5)
19:54:07.207 | in index file
19:54:07.207 | new changes
19:54:07.207 | production
19:54:07.208 | true
19:54:07.208 | user: undefined
19:54:07.209 |  
19:54:07.216 | - info Generating static pages (3/5)
19:54:07.231 | - info Generating static pages (5/5)
19:54:07.428 | - info Finalizing page optimization...
19:54:07.431 |  
19:54:07.443 | Route (pages)                              Size     First Load JS
19:54:07.443 | ┌ ○ /                                      3.84 kB         134 kB
19:54:07.443 | ├   /_app                                  0 B             122 kB
19:54:07.443 | ├ ○ /404                                   182 B           122 kB
19:54:07.443 | ├ ○ /about                                 270 B           122 kB
19:54:07.443 | ├ λ /admin                                 13.8 kB         144 kB
19:54:07.443 | ├ λ /api/auth/[...auth0]                   0 B             122 kB
19:54:07.443 | ├ λ /api/auth/hook                         0 B             122 kB
19:54:07.443 | ├ λ /api/graphql                           0 B             122 kB
19:54:07.443 | ├ λ /api/upload-image                      0 B             122 kB
19:54:07.443 | ├ ○ /favorites                             3.5 kB          133 kB
19:54:07.443 | └ λ /link/[id]                             5.87 kB         136 kB
19:54:07.443 | + First Load JS shared by all              127 kB
19:54:07.443 | ├ chunks/framework-cda2f1305c3d9424.js   45.2 kB
19:54:07.444 | ├ chunks/main-6f0913649682f6ca.js        26.8 kB
19:54:07.445 | ├ chunks/pages/_app-080515f3b3b51fac.js  48.7 kB
19:54:07.445 | ├ chunks/webpack-87b3a303122f2f0d.js     995 B
19:54:07.445 | └ css/eea48206b604b5a0.css               4.92 kB
19:54:07.445 |  
19:54:07.445 | λ  (Server)  server-side renders at runtime (uses getInitialProps or getServerSideProps)
19:54:07.445 | ○  (Static)  automatically rendered as static HTML (uses no initial props)
19:54:07.445 |  
19:54:08.129 | Done in 33.43s.
19:54:11.246 | Traced Next.js server files in: 3.080s
19:54:14.128 | Created all serverless functions in: 2.880s
19:54:14.134 | Collected static files (public/, static/, .next/static): 4.086ms
19:54:15.663 | Build Completed in /vercel/output [1m]
19:54:16.246 | Deploying outputs...
19:54:24.378 | Deployment completed
19:54:29.654 | Uploading build cache [115.83 MB]...
19:54:32.320 | Build cache uploaded: 2.666s

Please help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions