Next.js Discord

Discord Forum

Prisma-related Build Error when Deploying with Vercel

Unanswered
RW posted this in #help-forum
Open in Discord
RWOP
I receive the following build error when attempting to deploy my [Next.js app](https://github.com/RW-77/fncomp-analytics-website) with vercel (via git repository):
21:19:42.983 
Module not found: Can't resolve '@/generated/prisma/client'
21:19:42.983 
  1 | import "dotenv/config";
21:19:42.983 
  2 | import { PrismaPg } from '@prisma/adapter-pg'
21:19:42.983 
> 3 | import { PrismaClient } from '@/generated/prisma/client'
21:19:42.984 
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
21:19:42.984 
  4 |
21:19:42.984 
  5 | const connectionString = `${process.env.DATABASE_URL}`
21:19:42.984 
  6 |
21:19:42.984 
21:19:42.984 
Import map: aliased to relative './generated/prisma/client' inside of [project]/
21:19:42.984 
21:19:42.984 
21:19:42.984 
Import trace:
21:19:42.984 
  Server Component:
21:19:42.984 
    ./lib/prisma.ts
21:19:42.984 
    ./app/tournaments/page.tsx
21:19:42.984 
21:19:42.984 
https://nextjs.org/docs/messages/module-not-found
21:19:42.984 
21:19:42.984 
21:19:42.984 
    at <unknown> (./lib/prisma.ts:3:1)
21:19:42.984 
    at <unknown> (https://nextjs.org/docs/messages/module-not-found)
21:19:43.039 
 ELIFECYCLE  Command failed with exit code 1.
21:19:43.060 
Error: Command "pnpm run build" exited with 1

It seems like Prisma is generating the client after Next.js tries to build, but my package.json includes a build script prisma generate && next build, so I'm not sure what's going on.
{
  "name": "fortnite-stats-website",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "prisma generate && next build",
    "start": "next start",
    "lint": "eslint",
    "postinstall": "prisma generate"
  },
  "dependencies": {
    // dependencies
  },
  "devDependencies": {
    // devDependencies
  }
}

If needed, the repository can be found [here](https://github.com/RW-77/fncomp-analytics-website)

6 Replies

Barbary Lion
hi did you check your build and deployment settings?
this is in vercel's settings
Barbary Lion
if you run the build script in your local env do you get the same error?
@Barbary Lion hi did you check your build and deployment settings?
RWOP
does the package.json not take care of that already?
RWOP
I guess my main question is whether I need to first host my DB before trying to deploy with vercel.

Running locally, I just have an .env file with my localhost DB url (which I'm don't think is even part of the repo), and I haven't taken any additional steps between that and deploying the whole site.