본문 바로가기
Log/Debugging

Day117_Error: Command "npm run build" exited with 1

by uxia 2024. 3. 8.

프로젝트를 Vercel로 배포하는 과정에서 오류가 났다.

오류 코드의 일부는 아래와 같다.


  
PrismaClientInitializationError: Prisma has detected that this project was built on Vercel, which caches dependencies. This leads to an outdated Prisma Client because Prisma's auto-generation isn't triggered. To fix this, make sure to run the `prisma generate` command during the build process.
Learn how:
...
errorCode: undefined
}
> Build error occurred
Error: Failed to collect page data for /api/system-prompt/[id]
at /vercel/path0/node_modules/next/dist/build/utils.js:1258:15
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
type: 'Error'
}
Error: Command "npm run build" exited with 1

 

Prisma Client가 Vercel 환경에서 캐시된 의존성으로 인해

올바르게 생성되지 않은 것이 원인이라고 한다.

 

GPT에게 물어본 결과

Prisma Client가 최신 상태로 생성되고 업데이트되도록 보장하기 위해

prisma generate 명령을 빌드 프로세스 동안 실행해야 한다.

 

그러기 위해서는 prisma generate를 빌드 스크립트에 추가해야한다.

 

VS Code의 해당 프로젝트에서 package.json 파일을 찾은 후

script 부분을 아래와 같이 수정해주면 된다.

 


  
"scripts": {
"build": "prisma generate && next build"
}

 

다른 코드가 써있다면 누락된 부분만 수정해주면 된다.

 

 

GitHub에 푸쉬 후 재배포했을 때 같은 오류가 또 나길래

아예 Vercel에서 삭제 후 다시 임포트했더니

성공적으로 배포가 됐다👍

 

 

https://my-chat-gpt-bice-phi.vercel.app/