“Error while deploying NextJS app to Vercel” 无法部署 NextJS 应用到 Vercel 时发生错误。

huangapple go评论91阅读模式
英文:

Error while deploying NextJS app to Vercel

问题

你好,我正在尝试将NEXT-JS应用部署到Vercel,但令人讨厌的是,即使在我的项目根目录下有app和pages文件夹,它仍然会给出下面的错误。我尝试在Google上找到解决方案,但我找不到与我的情况相同的解决方案。

这是我的文件结构:
enter image description here

英文:

Hi guys I am trying to deploy NEXT-JS App to Vercel but it keeps giving the error below annoyingly even I have app and pages folders under my project root. I tried to find the solution on google but I couldn't find the same as mine.
enter image description here

here is my folder structure
enter image description here

答案1

得分: 1

首先,请确保在你的 next.config.js 中没有禁用 appDir

不要有:

const nextConfig = {
  experimental: {
    appDir: false,
  }
}

期望的是:

const nextConfig = {
}

其次,请确保在你的 npm run build 命令之后没有其他内容,除非使用了 &&

不要有:

"build": "next build prisma generate"

期望的是:

"build": "next build && prisma generate"

如果没有使用 &&,next 会尝试将 prisma 用作目录根目录。

英文:

Firstly, make sure you don't have appDir disabled in your next.config.js.

No:

const nextConfig = {
  experimental: {
    appDir: false,
  }
}

Expected:

const nextConfig = {
}

Secondly, make sure nothing comes after your npm run build command, without the use of &&

No:

"build": "next build prisma generate"

Expected:

"build": "next build && prisma generate"

Without the && next will try to use prisma as a directory root.

huangapple
  • 本文由 发表于 2023年7月18日 14:48:37
  • 转载请务必保留本文链接:https://go.coder-hub.com/76710159.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定