Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

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

Closed
1 task done
YassinEldeeb opened this issue Jun 19, 2022 · 73 comments
Closed
1 task done
Labels
bug Issue was opened via the bug report template. Developer Experience Issues related to Next.js logs, Error overlay, etc.

Comments

@YassinEldeeb
Copy link

YassinEldeeb commented Jun 19, 2022

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.

@YassinEldeeb YassinEldeeb added the bug Issue was opened via the bug report template. label Jun 19, 2022
@balazsorban44 balazsorban44 added the Developer Experience Issues related to Next.js logs, Error overlay, etc. label Jun 22, 2022
@pulkitvyas08
Copy link

Facing the same issue

@huanlirui
Copy link

i have same issue !!

@huanlirui
Copy link

huanlirui commented Jul 13, 2022

Execute the steps of “ creating an optimized production build ” on the Linux server

node v14.17.0

@benzavision
Copy link

same issue

@MarcusHSmith
Copy link

Same issue for us

@UmerEdava
Copy link

The same issue still exists.... any remedies. In my case, it was hours I stuck at this "creating an optimized production build". And also I didn't run the development server in the background.

@boiboif
Copy link

boiboif commented Jul 28, 2022

same issue!

@iamharshad
Copy link

iamharshad commented Jul 29, 2022

Same issue for React.js project as well even when development server is not running on

@Dariocoding
Copy link

I have the same issue!!!

@zahydo
Copy link

zahydo commented Sep 1, 2022

Same Issue. In development it worked, but when I try to create the Docker image it stuck

@zahydo
Copy link

zahydo commented Sep 1, 2022

Same Issue. In development it worked, but when I try to create the Docker image it stuck

I solved with the next steps:

  1. Upgrading Next to v12.2.5.
  2. Removing local folders: .next, node_modules
  3. Installing dependencies again: yarn install
  4. Adding this to next-config.js: output: 'standalone'
  5. Adding the next paths to the .dockerignore:
    Dockerfile
    .dockerignore
    node_modules
    npm-debug.log
    README.md
    .next
    docker
    .git
  6. Creating the image again: docker build ...

@alexrintt
Copy link

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

Same issue but I wasn't aware that this was happening due the open dev webserver.

So the solution for me is on your title: close the development server, then run next build and next export (If you intend to deploy statically).

@XahidEx
Copy link

XahidEx commented Oct 23, 2022

I am still facing the same issue. Using the latest NextJs 12.3.2-canary.34 facing this issue since I'm trying 12.3.2-carany.+

@ruvaz
Copy link

ruvaz commented Oct 29, 2022

You can't have both dev and build at the same time.

I solved it very quickly when I realized that there were several nodejs processes open when there should only be 1, and killing all the nodejs processes that were running in the background solved it for me.

It can also happen that a build started to fail and got stuck in the background so you should kill all the nodejs you see running in the task manager. I am using Nextjs 13

@XahidEx
Copy link

XahidEx commented Oct 29, 2022

Mine was also solved. I faced this issue because a dependency wasn't comfortable with the latest nextjs. 🙃
Vercel didn't show the error anyway. It was just stuck. 😅

@LordOfTheThunder
Copy link

Mine was solved when downgrading from next 13 to next 12.2

@ruvaz
Copy link

ruvaz commented Oct 31, 2022

Try by Tracing warnings with node: npx cross-env NODE_OPTIONS="--trace-warnings" yarn build

@Krungleviciute
Copy link

Krungleviciute commented Nov 9, 2022

I am having the same issue! I tried all the possible solutions, but cannot find the reason why it's stuck on "Creating an optimized production build.."
I get

info  - Linting and checking validity of types  
info  - Disabled SWC as replacement for Babel because of custom Babel configuration ".babelrc" https://nextjs.org/docs/messages/swc-disabled
info  - Creating an optimized production build . .

Something is not compiling right maybe ?

@farro97
Copy link

farro97 commented 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.

@Krungleviciute
Copy link

Yeah, I tried that, I tried removing package-lock and node modules and reinstall everything.. Nothing helped. And I don't know where to even start debugging.
There might be something in the config file that blocking it.
I am trying to update to nextjs v12.3.2 and using antd 4.23.6.
In the next.config.js file under webpack config I had this block:

    if (isServer) {
      const antStyles = /antd\/.*?\/style.*?/;
      const origExternals = [...config.externals];
      config.externals = [
        (context, request, callback) => {
          if (request.match(antStyles)) return callback();
          if (typeof origExternals[0] === 'function') {
            origExternals[0](context, request, callback);
          } else {
            return callback();
          }
          return null;
        },
        ...(typeof origExternals[0] === 'function' ? [] : origExternals),
      ];

      config.module.rules.unshift({
        test: antStyles,
        use: 'null-loader',
      });
    }

when removed this block it gave me errors in the logs that it failed to compile and that it couldn't import Alert, message and badge components from antd (which I use more than just those).
I don't know what is causing everything and where is the issue

@boliveros18
Copy link

boliveros18 commented Nov 17, 2022

Mine was solved when downgrading from next 13 to next 12.2

To upgrade you can run the following command in the terminal:

npm install next@12
or

yarn add next@12

then, delete .next folder and build next project:

npm run build

@jucian0
Copy link

jucian0 commented Nov 25, 2022

I faced the same error using next v13, updating to 13.0.5 the error is gone.

@edgarhsanchez
Copy link

I faced the same error using next v13, updating to 13.0.5 the error is gone.

I'm on 13.0.2 and it hangs. I'm going to try to move to latest.

@edgarhsanchez
Copy link

Moving to 13.0.5 worked. Makes me think there is some kind of bug that keeps creeping up in the builder since I see it's been showing up in different versions going back to 12.x.x

@asimashfaq
Copy link

My stuck due to tailwind. I remove those and it work.

@aitdahane
Copy link

aitdahane commented Dec 22, 2022

Any new about it. I am having the same problem when building docker image and upgrading from node 14 to node 16

@jelmd
Copy link

jelmd commented May 1, 2023

FWIW: I got finally a clean build by adjusting the versions in package.json to most recent ones, rm -rf .next node_modules; npm cache clean --force; npm update.

Even so npm cache clean emits bloat about self-healing and bla, --force was required to be able to fetch latest versions/resolve dependencies as needed.

Dependencies used:

	"dependencies": {
		"@next-auth/prisma-adapter": "^1.0.6",
		"@prisma/client": "^4.13.0",
		"next": "13.3.4",
		"nodemailer": "^6.9.1",
		"react": "18.2.0",
		"react-dom": "18.2.0"
	},
	"devDependencies": {
		"@types/node": "18.16.3",
		"@types/nodemailer": "^6.4.7",
		"@styled-icons/material": "^10.47.0",
		"@types/react": "18.2.0",
		"@types/react-dom": "18.2.1",
		"eslint": "8.39.0",
		"eslint-config-next": "13.3.4",
		"prisma": "^4.13.0",
		"typescript": "5.0.4"
	}

@ayushsgithub
Copy link

The same problem existed in my code also but it solved when I closed and restarted everything, but got another error Export encountered errors on following paths:
/
Error: Command "npm run build" exited with 1

@Josh-Savvy
Copy link

This is my own issue whenever I try to run a CI build for my nextjs typescript project:
Run eslint . --ext .js,.jsx,.ts,.tsx
eslint . --ext .js,.jsx,.ts,.tsx
shell: /usr/bin/bash -e {0}
##[debug]/usr/bin/bash -e /home/runner/work/_temp/d1b0ccf4-4fa4-4121-8209-9a8565b5a79d.sh
/home/runner/work/_temp/d1b0ccf4-4fa4-4121-8209-9a8565b5a79d.sh: line 1: eslint: command not found
Error: Process completed with exit code 127.
##[debug]Finishing: Run ESLint

@joacub
Copy link

joacub commented May 11, 2023

Having the same problem. Not working on 13.1.6, not working on 13.2.4 either, node 16.19 and 18.15 same behaviour. rebooted the pc to kill any possible process, no success. nuked the repository and cloned it, reinstalled everything clean, still not working. and there's no logs either, --debug does nothing.

Edit: Seems like next/font was not able to fetch some fonts and it does not handle the errors... found this by running build inside docker, but in my native shell no errors were reported.

same here, never finished, seems the next/font package in a docker env.

@aitdahane
Copy link

aitdahane commented May 28, 2023

In my case, it was related to some missing dependencies that were present as devDependencies. Check your package.json to see if it could help
If you use docker, check also your Dockerfile to see if there are some steps that delete necessary packages or code

@jszklarz
Copy link

If anyone else is having this issue I'll just put it out there what was happening to me.

Build was stuck on this state but would eventually finish after 10 minutes. This is a long time, specially on a Mac M1. I found out that while refactoring a few things I forgot to update the content on the tailwind config file. It was reading every .js/.ts file inside my huge /node_modules folder, on every single build.

Once I fixed that the build times went back to normal (30 seconds or less).

This was my issue also, thanks for saving me the time!

@SC0d3r
Copy link

SC0d3r commented Aug 7, 2023

I had the same issue and I found out the cause by adding this to my next.config.js - suggested by @andersekdahl

process.on('unhandledRejection', error => {
	console.log('unhandledRejection', error);
});

And I found out that the issue was the next build getting stuck when it couldn't download the fonts from Google. I turned off the VPN, and it worked.

@iiiok
Copy link

iiiok commented Sep 26, 2023

npm i next@latest
It is "next": "^13.5.3" now.

&& use this script to serve the output page:
(need to : [npm i serve -g] first)
"scripts": {
"html": "serve -s out"
},

@viictorcamposs
Copy link

FWIW: I got finally a clean build by adjusting the versions in package.json to most recent ones, rm -rf .next node_modules; npm cache clean --force; npm update.

Even so npm cache clean emits bloat about self-healing and bla, --force was required to be able to fetch latest versions/resolve dependencies as needed.

Dependencies used:

	"dependencies": {
		"@next-auth/prisma-adapter": "^1.0.6",
		"@prisma/client": "^4.13.0",
		"next": "13.3.4",
		"nodemailer": "^6.9.1",
		"react": "18.2.0",
		"react-dom": "18.2.0"
	},
	"devDependencies": {
		"@types/node": "18.16.3",
		"@types/nodemailer": "^6.4.7",
		"@styled-icons/material": "^10.47.0",
		"@types/react": "18.2.0",
		"@types/react-dom": "18.2.1",
		"eslint": "8.39.0",
		"eslint-config-next": "13.3.4",
		"prisma": "^4.13.0",
		"typescript": "5.0.4"
	}

I was having problem when trying to build and also when running npm run dev in my project with contentlayer
after I killed every process running on tcp:3000 and followed this comment, it finally worked for me
thanks @jelmd

i'm still using next 13.4.2

@MattiaPeiretti
Copy link

MattiaPeiretti commented Nov 5, 2023

When I run npm run build inside a docker container. It never builds and is for me stuck on "Creating an optimized production build ..." as well
image

I followed Vercel's guide on dockerisation and their freshly cloned example also hangs forever. If you check the picture above, mine is still hanging after running for 6200+ seconds (1h+).

The problem is very likely not:

  • Version, everything is up to date as of 06.10.2023
  • RAM, docker has 20 GB of RAM it can use

What I noticed about the docker build command (both tested for fresh Vercel example as well as my own dockerised project(nextjs project with app dir)), is that on macOS Sonoma, it hangs forever. HOWEVER, if I pull the same exact files and build the project on my Linux PopOs machine, it builds just fine.

So for me, it could be a configuration issue or some Docker-Sonoma issue.

Does anyone else see themselves in this issue as well?

@zahidhussain998
Copy link

I Solved This Same Issue by Just Simpling Follow This Steps

Run yarn next build to create a production build of your Next.js application. This command will compile your code and generate the necessary files.
bash
Copy code

> yarn next build

After the build is completed successfully, you can then run yarn next export to generate the static files:
bash
Copy code

> yarn next export

This sequence ensures that the necessary production build is available for the export command to work with. Once the export command completes, you should have your static files ready for deployment.

Make sure to follow these steps in the correct order to resolve the issue.

@yeasin72
Copy link

yeasin72 commented Nov 9, 2023

is there any solution to fix it

@Wishrem
Copy link

Wishrem commented Nov 9, 2023

When I run npm run build inside a docker container. It never builds and is for me stuck on "Creating an optimized production build ..." as well image

I followed Vercel's guide on dockerisation and their freshly cloned example also hangs forever. If you check the picture above, mine is still hanging after running for 6200+ seconds (1h+).

The problem is very likely not:

  • Version, everything is up to date as of 06.10.2023
  • RAM, docker has 20 GB of RAM it can use

What I noticed about the docker build command (both tested for fresh Vercel example as well as my own dockerised project(nextjs project with app dir)), is that on macOS Sonoma, it hangs forever. HOWEVER, if I pull the same exact files and build the project on my Linux PopOs machine, it builds just fine.

So for me, it could be a configuration issue or some Docker-Sonoma issue.

Does anyone else see themselves in this issue as well?

the same. have you solved this problem? i almost tried everything i could do. delete the cache, update dependency to latest version, but it is still stucking on the step.

And i tried to build this project in local, it completed very soon. But stuck on the step when i build it in docker.

@Wishrem
Copy link

Wishrem commented Nov 10, 2023

When I run npm run build inside a docker container. It never builds and is for me stuck on "Creating an optimized production build ..." as well image
I followed Vercel's guide on dockerisation and their freshly cloned example also hangs forever. If you check the picture above, mine is still hanging after running for 6200+ seconds (1h+).
The problem is very likely not:

  • Version, everything is up to date as of 06.10.2023
  • RAM, docker has 20 GB of RAM it can use

What I noticed about the docker build command (both tested for fresh Vercel example as well as my own dockerised project(nextjs project with app dir)), is that on macOS Sonoma, it hangs forever. HOWEVER, if I pull the same exact files and build the project on my Linux PopOs machine, it builds just fine.
So for me, it could be a configuration issue or some Docker-Sonoma issue.
Does anyone else see themselves in this issue as well?

the same. have you solved this problem? i almost tried everything i could do. delete the cache, update dependency to latest version, but it is still stucking on the step.

And i tried to build this project in local, it completed very soon. But stuck on the step when i build it in docker.

i fixed that by using OrbStack to use 'docker build' command. The problem seems to be caused by Docker Desktop.

@michaelmohamed
Copy link

When I run npm run build inside a docker container. It never builds and is for me stuck on "Creating an optimized production build ..." as well image
I followed Vercel's guide on dockerisation and their freshly cloned example also hangs forever. If you check the picture above, mine is still hanging after running for 6200+ seconds (1h+).
The problem is very likely not:

  • Version, everything is up to date as of 06.10.2023
  • RAM, docker has 20 GB of RAM it can use

What I noticed about the docker build command (both tested for fresh Vercel example as well as my own dockerised project(nextjs project with app dir)), is that on macOS Sonoma, it hangs forever. HOWEVER, if I pull the same exact files and build the project on my Linux PopOs machine, it builds just fine.
So for me, it could be a configuration issue or some Docker-Sonoma issue.
Does anyone else see themselves in this issue as well?

the same. have you solved this problem? i almost tried everything i could do. delete the cache, update dependency to latest version, but it is still stucking on the step.
And i tried to build this project in local, it completed very soon. But stuck on the step when i build it in docker.

i fixed that by using OrbStack to use 'docker build' command. The problem seems to be caused by Docker Desktop.

This!!!!!

Docker Desktop is the problem. For anyone trying to run next build in a container, via Docker Desktop on Mac M1/M2.

My builds would often fail, and sporadically work. When it worked, it could take 30 minutes to an hours.

I switched to OrbStack and the build worked flawlessly, in about 2 minutes.

@edvinerikson
Copy link

edvinerikson commented Nov 15, 2023

Facing the same issue. Worked fine before updating to macOS Sonoma. Should create a new issue for this as it doesn't seem related to the original issue.

@akd-io
Copy link
Contributor

akd-io commented Nov 16, 2023

I'm also facing builds getting stuck. No docker in my setup. During both next build and next dev. I am on an M1 Max, macOS Ventura 13.5.2. next@14.0.2.

I get the following output running next build:

$ DEBUG=true bun run next build
   ▲ Next.js 14.0.2
   - Environments: .env.production.local, .env



Source path: /Users/akd/workspace/my-project/app/globals.css
Setting up new context...
Finding changed files: 915.405ms
   Creating an optimized production build  ..

and similar output from next dev and going to localhost:3000:

$ DEBUG=true bun run next dev  
   ▲ Next.js 14.0.2
   - Local:        http://localhost:3000
   - Environments: .env

 ✓ Ready in 2.2s
 ○ Compiling / ...


Source path: /Users/akd/workspace/my-project/app/globals.css
Setting up new context...
Finding changed files: 944.431ms

CPU usage goes to 100% in these states. Need to force quit the next process.

Edit: Fixed it. I had messed up my Tailwind config.

My tailwind.config.js looked like

/** @type {import('tailwindcss/types').Config} */
const config = {
  content: ["./**/*.{js,ts,jsx,tsx}"],
  //...
}
module.exports = config

That's a content glob that's going to make the compiler traverse all node_modules directories.

Fixed it with

/** @type {import('tailwindcss/types').Config} */
const config = {
  content: [
    "./**/*.{js,ts,jsx,tsx}", // Include all matching files
    "!./node_modules/**", // Exclude everything in node_modules
  ],
  //...
};
module.exports = config;

@marcosnataqs
Copy link

When I run npm run build inside a docker container. It never builds and is for me stuck on "Creating an optimized production build ..." as well image
I followed Vercel's guide on dockerisation and their freshly cloned example also hangs forever. If you check the picture above, mine is still hanging after running for 6200+ seconds (1h+).
The problem is very likely not:

  • Version, everything is up to date as of 06.10.2023
  • RAM, docker has 20 GB of RAM it can use

What I noticed about the docker build command (both tested for fresh Vercel example as well as my own dockerised project(nextjs project with app dir)), is that on macOS Sonoma, it hangs forever. HOWEVER, if I pull the same exact files and build the project on my Linux PopOs machine, it builds just fine.
So for me, it could be a configuration issue or some Docker-Sonoma issue.
Does anyone else see themselves in this issue as well?

the same. have you solved this problem? i almost tried everything i could do. delete the cache, update dependency to latest version, but it is still stucking on the step.
And i tried to build this project in local, it completed very soon. But stuck on the step when i build it in docker.

i fixed that by using OrbStack to use 'docker build' command. The problem seems to be caused by Docker Desktop.

This!!!!!

Docker Desktop is the problem. For anyone trying to run next build in a container, via Docker Desktop on Mac M1/M2.

My builds would often fail, and sporadically work. When it worked, it could take 30 minutes to an hours.

I switched to OrbStack and the build worked flawlessly, in about 2 minutes.

That was the solution for me as well. I've switched to OrbStack and it worked seamlessly.

@percy507
Copy link

I solved it by fixed eslint version.

    "eslint": "8.34.0",
    "eslint-config-next": "13.2.1",

@MattiaPeiretti
Copy link

When I run npm run build inside a docker container. It never builds and is for me stuck on "Creating an optimized production build ..." as well image
I followed Vercel's guide on dockerisation and their freshly cloned example also hangs forever. If you check the picture above, mine is still hanging after running for 6200+ seconds (1h+).
The problem is very likely not:

  • Version, everything is up to date as of 06.10.2023
  • RAM, docker has 20 GB of RAM it can use

What I noticed about the docker build command (both tested for fresh Vercel example as well as my own dockerised project(nextjs project with app dir)), is that on macOS Sonoma, it hangs forever. HOWEVER, if I pull the same exact files and build the project on my Linux PopOs machine, it builds just fine.
So for me, it could be a configuration issue or some Docker-Sonoma issue.
Does anyone else see themselves in this issue as well?

the same. have you solved this problem? i almost tried everything i could do. delete the cache, update dependency to latest version, but it is still stucking on the step.
And i tried to build this project in local, it completed very soon. But stuck on the step when i build it in docker.

i fixed that by using OrbStack to use 'docker build' command. The problem seems to be caused by Docker Desktop.

This!!!!!
Docker Desktop is the problem. For anyone trying to run next build in a container, via Docker Desktop on Mac M1/M2.
My builds would often fail, and sporadically work. When it worked, it could take 30 minutes to an hours.
I switched to OrbStack and the build worked flawlessly, in about 2 minutes.

That was the solution for me as well. I've switched to OrbStack and it worked seamlessly.

Great to hear! I will try this.
For now, I have either used GitHub actions which run Ubuntu, or my own VPS. I'm really looking forward to trying OrbStack!

@jpbalarini
Copy link

jpbalarini commented Dec 1, 2023

When I run npm run build inside a docker container. It never builds and is for me stuck on "Creating an optimized production build ..." as well image

I followed Vercel's guide on dockerisation and their freshly cloned example also hangs forever. If you check the picture above, mine is still hanging after running for 6200+ seconds (1h+).

The problem is very likely not:

  • Version, everything is up to date as of 06.10.2023
  • RAM, docker has 20 GB of RAM it can use

What I noticed about the docker build command (both tested for fresh Vercel example as well as my own dockerised project(nextjs project with app dir)), is that on macOS Sonoma, it hangs forever. HOWEVER, if I pull the same exact files and build the project on my Linux PopOs machine, it builds just fine.

So for me, it could be a configuration issue or some Docker-Sonoma issue.

Does anyone else see themselves in this issue as well?

In my case, I suspected that it was some virtualization issue, and I was right. Once I disabled Rosetta for x86/amd64 emulation in my Docker desktop config I was able to build my image successfully!

Screenshot 2023-12-01 at 12 18 20

@MattiaPeiretti
Copy link

When I run npm run build inside a docker container. It never builds and is for me stuck on "Creating an optimized production build ..." as well image
I followed Vercel's guide on dockerisation and their freshly cloned example also hangs forever. If you check the picture above, mine is still hanging after running for 6200+ seconds (1h+).
The problem is very likely not:

  • Version, everything is up to date as of 06.10.2023
  • RAM, docker has 20 GB of RAM it can use

What I noticed about the docker build command (both tested for fresh Vercel example as well as my own dockerised project(nextjs project with app dir)), is that on macOS Sonoma, it hangs forever. HOWEVER, if I pull the same exact files and build the project on my Linux PopOs machine, it builds just fine.
So for me, it could be a configuration issue or some Docker-Sonoma issue.
Does anyone else see themselves in this issue as well?

the same. have you solved this problem? i almost tried everything i could do. delete the cache, update dependency to latest version, but it is still stucking on the step.
And i tried to build this project in local, it completed very soon. But stuck on the step when i build it in docker.

i fixed that by using OrbStack to use 'docker build' command. The problem seems to be caused by Docker Desktop.

This!!!!!
Docker Desktop is the problem. For anyone trying to run next build in a container, via Docker Desktop on Mac M1/M2.
My builds would often fail, and sporadically work. When it worked, it could take 30 minutes to an hours.
I switched to OrbStack and the build worked flawlessly, in about 2 minutes.

That was the solution for me as well. I've switched to OrbStack and it worked seamlessly.

Great to hear! I will try this. For now, I have either used GitHub actions which run Ubuntu, or my own VPS. I'm really looking forward to trying OrbStack!

I tried OrbStack, it gave a nice performance boost, but it did not solve the issue.

@auxibee
Copy link

auxibee commented Dec 10, 2023

I solved this issue by using CMD in the final build step instead of RUN

RUN npm run build

CMD [ "npm", "run", "start" ]

@theneroweb
Copy link

i just upgraded nodejs to the latest version and worked like a charm
previous version 17.9.1 to 20.10.0

@parlato-vooma
Copy link

I had the same issue and I found out the cause by adding this to my next.config.js - suggested by @andersekdahl

process.on('unhandledRejection', error => {
	console.log('unhandledRejection', error);
});

Extremely helpful - we'd removed a dependency with a transitive dependency we relied on implicitly. We were only able to determine this with the above process log.

@HajAbdolblack
Copy link

I actually had this problem and I managed to fix it by upgrading my Linux machine memory

@samcx
Copy link
Member

samcx commented Jan 2, 2024

Hi everyone!

I will be moving this to :nextjs: Discussions, as this issue can arise from a variety of different ways, and different solutions to resolve those.

We still encourage folks to file bugs outside of this thread detailing the exact issue, with a :repro: and details on how to consistently reproduce the issue!

Happy 2024!

@vercel vercel locked and limited conversation to collaborators Jan 2, 2024
@samcx samcx converted this issue into discussion #60147 Jan 2, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
bug Issue was opened via the bug report template. Developer Experience Issues related to Next.js logs, Error overlay, etc.
Projects
None yet
Development

No branches or pull requests