部署未成功:部署目录“out"不存在 [英] Deploy did not succeed: Deploy directory 'out' does not exist

查看:31
本文介绍了部署未成功:部署目录“out"不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将使用Next.js创建的应用部署到netlify时,出现如下错误,部署失败.

When deploying an app created with Next.js to netlify, the following error occurs and the deployment fails.

────────────────────────────────────────────────────────────────
  6. Deploy site                                                
────────────────────────────────────────────────────────────────
​
​
────────────────────────────────────────────────────────────────
  Configuration error                                           
────────────────────────────────────────────────────────────────
​
  Error message
  Deploy did not succeed: Deploy directory 'out' does not exist
​
  Resolved config
  build:
    command: yarn build
    commandOrigin: config
    publish: /opt/build/repo/out
  plugins:
    - inputs: {}
      origin: config
      package: '@netlify/plugin-nextjs'
    - inputs: {}
      origin: config
      package: netlify-plugin-cache-nextjs
Caching artifacts
Started saving node modules
Finished saving node modules
Started saving build plugins
Finished saving build plugins
Started saving yarn cache
Finished saving yarn cache
Started saving pip cache
Finished saving pip cache
Started saving emacs cask dependencies
Finished saving emacs cask dependencies
Started saving maven dependencies
Finished saving maven dependencies
Started saving boot dependencies
Finished saving boot dependencies
Started saving rust rustup cache
Finished saving rust rustup cache
Started saving go dependencies
Finished saving go dependencies
Build failed due to a user error: Build script returned non-zero exit code: 2
Failing build: Failed to build site
Failed during stage 'building site': Build script returned non-zero exit code: 2
Finished processing build request in 1m25.310488139s

各种文件和设置如下所示.

The various files and settings are shown below.

netlify.toml

[build]
  command = "yarn build"
  publish = "out"

[[plugins]]
  package = "@netlify/plugin-nextjs"

[[plugins]]
  package = "netlify-plugin-cache-nextjs"

package.json

...
"scripts": {
  "dev": "next",
  "build": "next build",
  "start": "next start",
  "export": "next export"
},
...

Netlify |构建设置

各种设置基于以下页面.

The various settings are based on the following pages.

如果你知道如何解决这个问题,请告诉我.
我愿意接受任何想法.

If you know how to solve this problem, please let me know.
I'm open to any ideas.

推荐答案

您在 netlify.toml 文件中的构建命令中缺少 yarn export.由于没有调用 next export,因此 out/ 文件夹将不存在.

You are missing yarn export in the build command inside your netlify.toml file. Since next export doesn't get called, the out/ folder will not exist.

[build]
  command = "yarn build && yarn export"
  publish = "out"

...

这篇关于部署未成功:部署目录“out"不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆