Netlify 上的 NextJS:部署没有成功;部署目录 'out' 不存在
NextJS on Netlify: Deploy did not succeed; Deploy directory 'out' does not exist
我目前正在开发一个网站并将其托管在 Netlify 上。直到最近的一次更改,它的部署一直没有问题。然而,我推动了一个变化,突然间,我得到了这个错误; Deploy did not succeed: Deploy directory 'out' does not exist
。
我知道这里和其他论坛上有很多类似的问题,但我已经尝试了这些解决方案及其组合但没有成功。
我查看的来源:
- https://answers.netlify.com/t/failed-during-stage-building-site-deploy-directory-out-does-not-exist/30986
- https://docs.netlify.com/configure-builds/troubleshooting-tips/?_ga=2.156848827.1277875653.1616642374-301736030.1616521229
这里是 GitHub 存储库:https://github.com/henrikvtcodes/henrikvt.com-nextjs-old
我尝试过的事情:
- 将
"export":"next export"
添加到 package.json 并将我的构建命令更改为 next build && next export
- 将
"export":"next build && next export"
添加到 package.json 并将我的构建命令更改为 npm run export
- 标准
npm run build
- 还有很多(可以在 GitHub 上的提交历史中看到)
所有这些都失败并出现上述错误代码或退出代码 1。
我不知道该怎么办。标准 npm run build
命令在我的本地系统上也运行得很好。另一条可能有用的信息;我在 Vercel 上测试部署了相同的存储库并且运行良好(有点符合预期)但出于多种原因我宁愿使用 Netlify。
当您有 next.config.js 时,添加 target: serverless
。该文件将如下所示:
// next.config.js
module.exports = {
future: {
webpack5: true,
},
target: 'serverless'
}
然后你可以做的是将一个 netlify.toml
文件添加到你的项目的根目录,告诉 Netlify 它应该 运行 像这样的构建命令:
// netlify.toml
[build]
command = "yarn build"
这使我的 Next.js 部署到 Netlify 工作。
我目前正在开发一个网站并将其托管在 Netlify 上。直到最近的一次更改,它的部署一直没有问题。然而,我推动了一个变化,突然间,我得到了这个错误; Deploy did not succeed: Deploy directory 'out' does not exist
。
我知道这里和其他论坛上有很多类似的问题,但我已经尝试了这些解决方案及其组合但没有成功。
我查看的来源:
- https://answers.netlify.com/t/failed-during-stage-building-site-deploy-directory-out-does-not-exist/30986
- https://docs.netlify.com/configure-builds/troubleshooting-tips/?_ga=2.156848827.1277875653.1616642374-301736030.1616521229
这里是 GitHub 存储库:https://github.com/henrikvtcodes/henrikvt.com-nextjs-old
我尝试过的事情:
- 将
"export":"next export"
添加到 package.json 并将我的构建命令更改为next build && next export
- 将
"export":"next build && next export"
添加到 package.json 并将我的构建命令更改为npm run export
- 标准
npm run build
- 还有很多(可以在 GitHub 上的提交历史中看到)
所有这些都失败并出现上述错误代码或退出代码 1。
我不知道该怎么办。标准 npm run build
命令在我的本地系统上也运行得很好。另一条可能有用的信息;我在 Vercel 上测试部署了相同的存储库并且运行良好(有点符合预期)但出于多种原因我宁愿使用 Netlify。
当您有 next.config.js 时,添加 target: serverless
。该文件将如下所示:
// next.config.js
module.exports = {
future: {
webpack5: true,
},
target: 'serverless'
}
然后你可以做的是将一个 netlify.toml
文件添加到你的项目的根目录,告诉 Netlify 它应该 运行 像这样的构建命令:
// netlify.toml
[build]
command = "yarn build"
这使我的 Next.js 部署到 Netlify 工作。