Jul 3, 2022
cPanel Access Level
Website Owner
Hi so i'm using hosting provider that use cpanel, when i try to run npm run build on my hosting the build failed but when i try on my local it's work perfectly

Below is the error from my screen
[github-repo/web-180dcugm (14)] [[email protected] web-180dcugm]$ npm run build

> [email protected] build /home/u3161605/github-repo/web-180dcugm
> next build

info - Loaded env from /home/u3161605/github-repo/web-180dcugm/.env
info - Using webpack 5. Reason: Enabled by default webpack5 | Next.js
info - Checking validity of types
throw er; // Unhandled 'error' event

Error: spawn /opt/alt/alt-nodejs14/root/usr/bin/node EAGAIN
at Process.ChildProcess._handle.onexit (internal/child_process.js:274:19)
at onErrorNT (internal/child_process.js:469:16)
at processTicksAndRejections (internal/process/task_queues.js:82:21)
Emitted 'error' event on ChildProcess instance at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:280:12)
at onErrorNT (internal/child_process.js:469:16)
at processTicksAndRejections (internal/process/task_queues.js:82:21) {
errno: -11,
code: 'EAGAIN',
syscall: 'spawn /opt/alt/alt-nodejs14/root/usr/bin/node',
path: '/opt/alt/alt-nodejs14/root/usr/bin/node',
spawnargs: [
npm ERR! errno 1
npm ERR! [email protected] build: `next build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /home/u3161605/.npm/_logs/2022-07-03T07_37_56_237Z-debug.log
And this is error from the logs
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli '/opt/alt/alt-nodejs14/root/usr/bin/node',
1 verbose cli '/opt/alt/alt-nodejs14/root/usr/bin/npm',
1 verbose cli 'run',
1 verbose cli 'build'
1 verbose cli ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle w[email protected]~prebuild: [email protected]
6 info lifecycle [email protected]~build: [email protected]
7 verbose lifecycle [email protected]~build: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]~build: PATH: /opt/alt/alt-nodejs14/root/usr/lib/node_modules/npm/node_modules.bundled/npm-lifecycle/node-gyp-bin:/home/u3161605/github-repo/web-180dcugm/node_modules/.bin:/opt/alt/alt-nodejs14/root/usr/bin:/home/u3161605/nodevenv/github-repo/web-180dcugm/14/bin:/opt/alt/alt-nodejs14/root/usr/bin:/home/u3161605/nodevenv/github-repo/web-180dcugm/14/lib/bin/:/usr/local/cpanel/3rdparty/lib/path-bin:/usr/local/jdk/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/usr/local/bin:/usr/X11R6/bin:/root/bin:/opt/bin:/opt/cpanel/composer/bin:/home/u3161605/.local/bin:/home/u3161605/bin
9 verbose lifecycle [email protected]~build: CWD: /home/u3161605/github-repo/web-180dcugm
10 silly lifecycle [email protected]~build: Args: [ '-c', 'next build' ]
11 silly lifecycle [email protected]~build: Returned: code: 1 signal: null
12 info lifecycle [email protected]~build: Failed to exec build script
13 verbose stack Error: [email protected] build: `next build`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (/opt/alt/alt-nodejs14/root/usr/lib/node_modules/npm/node_modules.bundled/npm-lifecycle/index.js:332:16)
13 verbose stack at EventEmitter.emit (events.js:400:28)
13 verbose stack at ChildProcess.<anonymous> (/opt/alt/alt-nodejs14/root/usr/lib/node_modules/npm/node_modules.bundled/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:400:28)
13 verbose stack at maybeClose (internal/child_process.js:1058:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:293:5)
14 verbose pkgid [email protected]
15 verbose cwd /home/u3161605/github-repo/web-180dcugm
16 verbose Linux 4.18.0-305.10.2.2.lve.el7h.x86_64
17 verbose argv "/opt/alt/alt-nodejs14/root/usr/bin/node" "/opt/alt/alt-nodejs14/root/usr/bin/npm" "run" "build"
18 verbose node v14.18.3
19 verbose npm v6.14.15
20 error code ELIFECYCLE
21 error errno 1
22 error [email protected] build: `next build`
22 error Exit status 1
23 error Failed at the [email protected] build script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
Last edited by a moderator:


Jurassic Moderator
Staff member
Oct 19, 2014
cPanel Access Level
Root Administrator
Hey there! Are you using the NodeJS provided through cPanel here? How to Install a Node.js Application | cPanel & WHM Documentation

We don't require that command to get run as part of our tool, but our support for NodeJS is very limited, as outlined at the top of that document. I also see this is located in /opt/alt/alt-nodejs14 - are you using the CloudLinux Selector tool for this work? If so, it might be best to reach out to them directly as the cPanel tools use version 16.


Well-Known Member
Aug 10, 2001
Guessing you're using CloudLinux? You'll need to limit the number of threads & processes that NextJS is using. Open up your next.conf.js and add the experimental section:
module.exports = {
experimental: {
workerThreads: false,
cpus: 4
You might need to adjust the cpus value still.

As there's jest in there as well, you might need to tell that to run inline or limit the number of workers as well, for that you'll need to open up your package.json and check the scripts section:
"scripts": {
"test": "jest --maxWorkers=4"

"scripts": {
"test": "jest --runInBand"
You can read a bit more about the former in the blog post I wrote after solving the issue for a customer: Fixing Next.js "Error: spawn EAGAIN, errno: -11" on cPanel and Plesk with CloudLinux -