I need to build my next js project inside the cpanel so I dont have to build it locally and upload it every time.
I tried running the build script in the cpanel using the "setup Node.js app" and this is the error I get :
client@0.1.0 build /home/bazztn/front next build
info - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5 info - Checking validity of types... stderr: events.js:377 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: [ '/home/bazztn/nodevenv/front/14/lib/node_modules/jest-worker/build/workers/processChild.js' ] } npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! client@0.1.0 build:
next build
npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the client@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/bazztn/.npm/_logs/2022-04-10T16_24_44_597Z-debug.log
You should be fully able to do so. I am personally hosting a Nuxt and Next projects on a cPanel host without none issues so far.
The easiest way to deploy any NodeJS app is to use CloudLinux's NodeJS Selector and the good part of it is that you can also choose which Node version to be used for your app (no matter the server's default node version or whatsoever).
Having that said, I would highly recommend you just find a cPanel host which does come with the NodeJS feature.