NodeJS failed to run npm build
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
[QUOTE]
[github-repo/web-180dcugm (14)] [u3161605@srv52 web-180dcugm]$ npm run build
> web-180dcugm@0.1.0 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 web-180dcugm@0.1.0 build: `next build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the web-180dcugm@0.1.0 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 [QUOTE] 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 npm@6.14.15 3 info using node@v14.18.3 4 verbose run-script [ 'prebuild', 'build', 'postbuild' ] 5 info lifecycle web-180dcugm@0.1.0~prebuild: web-180dcugm@0.1.0 6 info lifecycle web-180dcugm@0.1.0~build: web-180dcugm@0.1.0 7 verbose lifecycle web-180dcugm@0.1.0~build: unsafe-perm in lifecycle true 8 verbose lifecycle web-180dcugm@0.1.0~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 web-180dcugm@0.1.0~build: CWD: /home/u3161605/github-repo/web-180dcugm 10 silly lifecycle web-180dcugm@0.1.0~build: Args: [ '-c', 'next build' ] 11 silly lifecycle web-180dcugm@0.1.0~build: Returned: code: 1 signal: null 12 info lifecycle web-180dcugm@0.1.0~build: Failed to exec build script 13 verbose stack Error: web-180dcugm@0.1.0 build: `next build` 13 verbose stack Exit status 1 13 verbose stack at EventEmitter. (/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. (/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 web-180dcugm@0.1.0 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 web-180dcugm@0.1.0 build: `next build` 22 error Exit status 1 23 error Failed at the web-180dcugm@0.1.0 build script. 23 error This is probably not a problem with npm. There is likely additional logging output above. 24 verbose exit [ 1, true ]
And this is error from the logs [QUOTE] 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 npm@6.14.15 3 info using node@v14.18.3 4 verbose run-script [ 'prebuild', 'build', 'postbuild' ] 5 info lifecycle web-180dcugm@0.1.0~prebuild: web-180dcugm@0.1.0 6 info lifecycle web-180dcugm@0.1.0~build: web-180dcugm@0.1.0 7 verbose lifecycle web-180dcugm@0.1.0~build: unsafe-perm in lifecycle true 8 verbose lifecycle web-180dcugm@0.1.0~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 web-180dcugm@0.1.0~build: CWD: /home/u3161605/github-repo/web-180dcugm 10 silly lifecycle web-180dcugm@0.1.0~build: Args: [ '-c', 'next build' ] 11 silly lifecycle web-180dcugm@0.1.0~build: Returned: code: 1 signal: null 12 info lifecycle web-180dcugm@0.1.0~build: Failed to exec build script 13 verbose stack Error: web-180dcugm@0.1.0 build: `next build` 13 verbose stack Exit status 1 13 verbose stack at EventEmitter. (/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. (/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 web-180dcugm@0.1.0 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 web-180dcugm@0.1.0 build: `next build` 22 error Exit status 1 23 error Failed at the web-180dcugm@0.1.0 build script. 23 error This is probably not a problem with npm. There is likely additional logging output above. 24 verbose exit [ 1, true ]
-
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. 0 -
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: [QUOTE] 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: [QUOTE] { "scripts": { "test": "jest --maxWorkers=4" } }
or [QUOTE] { "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: Thanks, Karl0
Please sign in to leave a comment.
Comments
2 comments