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.

Stuck on `Creating an optimized production build` forever when development server is running

See original GitHub issue

Verify canary release

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

Provide environment information

Operating System: Platform: win32 Arch: x64 Version: Windows 10 Pro Binaries: Node: 16.13.0 npm: N/A Yarn: N/A pnpm: 6.24.0-1 Relevant packages: next: 12.1.4 react: 17.0.2 react-dom: 17.0.2

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

Describe the Bug

I had my development server running in the background without me remembering and I wanted to build my app using next build, that’s what I’ve got:

$ yarn next build
yarn run v1.22.17
$ C:\development\activity-builder\node_modules\.bin\next build
info  - Loaded env from C:\development\activity-builder\.env
info  - Checking validity of types  
warn  - The Next.js plugin was not detected in your ESLint configuration. See https://nextjs.org/docs/basic-features/eslint#migrating-existing-config

./src/components/Activities/ActivityQuestions/DynamicQuestionTypes/MultipleChoice.tsx  
68:40  Warning: Forbidden non-null assertion.  @typescript-eslint/no-non-null-assertion
69:22  Warning: Forbidden non-null assertion.  @typescript-eslint/no-non-null-assertion

./src/components/Activities/ActivityQuestions/Question.tsx
102:13  Warning: Unexpected console statement.  no-console

info  - Need to disable some ESLint rules? Learn more here: https://nextjs.org/docs/basic-features/eslint#disabling-rules
info  - Creating an optimized production build  

And I was stuck for 30 minutes on info - Creating an optimized production build without any indication of anything being wrong, I noticed that the development server was running, after I’ve shut it down and ran next build again It compiled successfully.

Expected Behavior

  • Run next build to compile the app for production even when I’m running the development server.

    OR

  • Notify me that the development server is running and needs to be shut down before running next build, that’s in case running next build when next is running isn’t possible.

Link to reproduction

https://github.com/YassinEldeeb/Next.js-starter

To Reproduce

  1. Run next for the development server.
  2. Then run next build while the development server is running.

Note: It’s not specific to the repository linked above.

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:11
  • Comments:27

github_iconTop GitHub Comments

4reactions
farro97commented, Nov 12, 2022

Make sure you don’t run development and build the at the same time. I got my build running forever till I closed my dev server and it completes my build process.

2reactions
LordOfTheThundercommented, Oct 29, 2022

Mine was solved when downgrading from next 13 to next 12.2

Read more comments on GitHub >

github_iconTop Results From Across the Web

Next Build hangs forever - Stack Overflow
Next build hangs at 'Creating an optimized production build' and hangs forever. Don't even know where to start to address this issue. Can...
Read more >
How To Optimize React App For Production And Deploy It To ...
Run the application by executing the following commands in sequence npm install npm run build npm run start-server. Open the Chrome developer tool...
Read more >
How To Optimize Your Next.js Production Build
1. Run the following command to add this package. npm install @next/bundle-analyzer cross-env 2. Next Bundle Analyzer works with the next build command....
Read more >
Build Performance - webpack
The following best practices should help, whether you're running build scripts in development or production. Stay Up to Date. Use the latest webpack...
Read more >
Deploy React-Node.js Application in a Virtual Machine
But in production, we don't use this development server. We create an optimised production build and serve it using the Nginx server.
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