Unverified Commit 2fd397ff authored by Connor Davis's avatar Connor Davis Committed by GitHub

Add error for exporting when target is not server (#6455)

parent 7dc50f38
# Using `next export` with `target` not set to `server`
#### Why This Error Occurred
Next.js can only handle exporting when the `target` is set to `server` (this is the default value). A serverless build, for instance, has no handler for requests–this is usually implemented by a hosting provider.
#### Possible Ways to Fix It
Change `target` to `server`, run `next build`, then run `next export` again.
\ No newline at end of file
......@@ -25,6 +25,8 @@ export default async function (dir, options, configuration) {
const threads = options.threads || Math.max(cpus().length - 1, 1)
const distDir = join(dir, nextConfig.distDir)
if (nextConfig.target !== 'server') throw new Error('Cannot export when target is not server. https://err.sh/zeit/next.js/next-export-serverless')
log(`> using build directory: ${distDir}`)
if (!existsSync(distDir)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment