Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Next Export does not generate any HTML files in /out dir #40240

Closed
1 task done
Jambre opened this issue Sep 5, 2022 · 3 comments
Closed
1 task done

Next Export does not generate any HTML files in /out dir #40240

Jambre opened this issue Sep 5, 2022 · 3 comments
Labels
bug Issue was opened via the bug report template.

Comments

@Jambre
Copy link

Jambre commented Sep 5, 2022

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 10 Pro
Binaries:
  Node: 16.17.0
  npm: N/A
  Yarn: N/A
  pnpm: N/A
Relevant packages:
  next: 12.2.6-canary.9
  eslint-config-next: 12.2.5
  react: 18.2.0
  react-dom: 18.2.0

Which example does this report relate to?

create-next-app

What browser are you using? (if relevant)

N/A

How are you deploying your application? (if relevant)

Static (To be uploaded to S3)

Describe the Bug

Following the direction from the docs, and this article- the export function did not generate the html files for static hosting.

I've tried defining an exportPathMap and setting trailingSlash to true which neither did not change the result.

Expected Behavior

On export the index.html and other defined /pages should be generated into the /out directory. However, only the _next/ directory is created in the /out dir.

Expanded folder shows all files in /out generated from the export command:
5376089db1e6d88b79bb586a446ce1bd

To Reproduce

  1. npx create-next-app@latest (currently 12.2.5)
  2. Change 'build' in package.json to next build && next export
  3. Run npm install
  4. Run npm run build
  5. With "exportPathMap" not being defined in next.config.js the command would generate a map from "./pages"
  6. Static HTML files would be available in /out but fails to appear.
@Jambre Jambre added the bug Issue was opened via the bug report template. label Sep 5, 2022
@rubytree33
Copy link
Contributor

I tried reproducing it and got this error after npm run build, and the resulting directory tree looks like yours.

Error: Image Optimization using Next.js' default loader is not compatible with `next export`.
  Possible solutions:
    - Use `next start` to run a server, which includes the Image Optimization API.
    - Configure `images.unoptimized = true` in `next.config.js` to disable the Image Optimization API.
  Read more: https://nextjs.org/docs/messages/export-image-api

After making the experimental fix suggested by the link, it works as expected.

@Jambre
Copy link
Author

Jambre commented Sep 6, 2022

@rubytree33

Thanks for helping me out. That'll do it! Perhaps I should be more considerate of the CLI output next time. Adding this to my next.config.js file made it functional for create-next-app:

images: {
  unoptimized: true,
},

Further, for my project it worked when wrapped with experimental:

experimental: {
  images: {
    unoptimized: true,
  },
},

This is covered in the docs here. Currently the static export docs page simply alludes to the setting under Image Optimization using a custom loader, however I would recommend that the documentation team to add a direct reference/step stating that image optimization needs to be disabled for exporting to work.

@Jambre Jambre closed this as completed Sep 6, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Oct 6, 2022

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

No branches or pull requests

2 participants