2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Next.jsをVercelにデプロイするとType error: Module '"@prisma/client"' has no exported member '***'.エラーが出る

Posted at

はじめに

Next.jsをVercelにデプロイしたらエラーが出たので解決方法を書きます。

問題

Next.jsのプロジェクトをVercelにデプロイした際に下記のようなエラーが発生しました。

VercelのDeploymentタブのログ
Type error: Module '"@prisma/client"' has no exported member 'Todo'.
> 1 | import { PrismaClient, Todo } from '@prisma/client'
    |                        ^
  2 | import { NextResponse } from 'next/server'
  3 |
  4 | const prisma = new PrismaClient()
Error: Command "npm run build" exited with 1

解決方法

Prismaの型であるTodoが見つけられないのが原因みたいです。

package.jsonのbuildコマンドを下記のように修正したらエラーがなくなりました。

package.json
"scripts": {
"dev": "next dev",
- "build": "next build",
+ "build": "prisma generate && prisma migrate deploy && next build",
"start": "next start",
"lint": "next lint"
},

おわりに

また一歩前進

参考にしたサイト

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?