question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Nextjs export step no longer working when build runs

See original GitHub issue

Describe the bug

Export step no longer working when running netlify build

My build function is defined in my package.json as is suggested by nextJS documentation:

{
    "build": "next build && next export",
}

It seems after version v11.6.0, the export command is skipped.

Steps to reproduce

Create a nextJS app with package.json defined as:

{
    "build": "next build && next export",
}

Run netlify build

Configuration

[build.environment] NEXT_PUBLIC_IS_PR_PREVIEW = ‘false’ NODE_VERSION = ‘16’ [context.deploy-preview.environment] NEXT_PUBLIC_IS_PR_PREVIEW = ‘true’

[dev] targetPort=4200

Environment

System: OS: macOS 12.5.1 CPU: (10) arm64 Apple M1 Pro Memory: 112.98 MB / 16.00 GB Shell: 5.8.1 - /bin/zsh Binaries: Node: 16.15.1 - ~/.nvm/versions/node/v16.15.1/bin/node Yarn: 1.22.15 - ~/.nvm/versions/node/v16.15.1/bin/yarn npm: 8.11.0 - ~/.nvm/versions/node/v16.15.1/bin/npm npmGlobalPackages: netlify-cli: 11.5.1

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
m-jovanoviccommented, Oct 30, 2022

Hey @tinfoil-knight, it sorted itself out after a few days. Once one of the packages was updated.

1reaction
tinfoil-knightcommented, Oct 30, 2022

@m-jovanovic Sorry for the delayed response.

I tried this out today with netlify-cli/12.0.11 & next/13.0.0.

  • Created the default app with npx create-next-app@latest
  • Changed the "build" script in package.json to next build && next export
  • Added a netlify.toml file with:
[build]
	command = "npm run build"

The static export is working for me. An out directory is created with all the files. Can you update both netlify-cli & next and see if you’re still experiencing the issue?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Next JS build failing due to ''Export encountered errors on ...
Like this, it works fine, but when I run my file independently (going to /Hero), it gives me an error. So fixing this...
Read more >
Going to Production - Next.js
Before taking your Next.js application to production, here are some recommendations to ensure the best user experience.
Read more >
Setting a custom build directory - next.config.js
Now if you run next build Next.js will use build instead of the default .next folder. distDir should not leave your project directory....
Read more >
Advanced Features: Static HTML Export - Next.js
Export your Next.js app to static HTML, and run it standalone without the need of a Node.js ... Running npm run build will...
Read more >
Advanced Features: Output File Tracing - Next.js
There are some cases in which Next.js might fail to include required files, or might incorrectly include unused files. In those cases, you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found