Next.js Discord

Discord Forum

Error Build - App Router - cPanel

Unanswered
Asiatic Lion posted this in #help-forum
Open in Discord
Asiatic LionOP
npm run build

> front-end@0.1.0 build
> next build

   â–² Next.js 14.0.4
   - Environments: .env

 ✓ Creating an optimized production build    
 ✓ Compiled successfully
 ✓ Linting and checking validity of types    
uncaughtException Error: spawn /home/myuser/.nvm/versions/node/v18.18.2/bin/node EAGAIN
    at ChildProcess._handle.onexit (node:internal/child_process:284:19)
    at onErrorNT (node:internal/child_process:477:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -11,
  code: 'EAGAIN',
  syscall: 'spawn /home/myuser/.nvm/versions/node/v18.18.2/bin/node',
  path: '/home/myuser/.nvm/versions/node/v18.18.2/bin/node',
  spawnargs: [
    '/home/myuser/myhost/node_modules/next/dist/compiled/jest-worker/processChild.js'
  ]
}


OS: Linux
Node Version: 18.18.2
In cPanel terminal

56 Replies

@joulev try this: https://kdaws.com/learn/fixing-next-js-error-spawn-errno-11-on-cpanel-and-plesk-with-cloudlinux/
Asiatic LionOP
i just tried this, but still error,
i am using cPanel and next 14.0.4 app router
@Ray same error?
Asiatic LionOP
yes
@Asiatic Lion yes
have you tried set cpus to 1?
cpus: 1
@Ray have you tried set cpus to 1? `cpus: 1`
Asiatic LionOP
i was and stuck linting
   â–² Next.js 14.0.4
   - Environments: .env
   - Experiments (use at your own risk):
     · cpus

 ✓ Creating an optimized production build    
 ✓ Compiled successfully
   Linting and checking validity of types  ...
Asiatic LionOP
how about export standalone?
i just tried that on my local and i found new errors, when i run node .next/standalone/server.js and open localhost:3000 JS files is not found and images is bad request
749-edb9e24670462805.js:1 
        
        
       Failed to load resource: the server responded with a status of 404 (Not Found)
page-224bb38b1e2df8d6.js:1 
        
        
       Failed to load resource: the server responded with a status of 404 (Not Found)
589-029791705fa11408.js:1 
        
        
       Failed to load resource: the server responded with a status of 404 (Not Found)
layout-8033a408314b1dfe.js:1 
        
        
       Failed to load resource: the server responded with a status of 404 (Not Found)
image:1 
        
        
       Failed to load resource: the server responded with a status of 400 (Bad Request)
image:1 
@Ray how many cpu does your node have?
Asiatic LionOP
$ nproc
8
@Ray set this in `next.config.js` ts output: 'standalone'
Asiatic LionOP
Yes, I have done it, and I encountered the errors above
so the build process success? and you tried to start the server with node .next/standalone/server.js?
@Ray so the build process success? and you tried to start the server with `node .next/standalone/server.js`?
Asiatic LionOP
yes, build is success in local, but when i open the localhost:3000, css, js, images is not loaded
yes because in standalone mode, you have to copy public and static folder manually
@Ray yes because in standalone mode, you have to copy public and static folder manually
Asiatic LionOP
cp ./public .next/standalone/
cp .next/static .next/standalone/.next/
to .next/standalone?
@Asiatic Lion to `.next/standalone`?
yes
@Ray yes
Asiatic LionOP
standalone solved thanks bro, now want to try up to cpanel
Asiatic LionOP
@Ray error 400 bad request image
GET https://myweb.com/_next/image?url=%2Fimages%2Fhello.jpg&w=384&q=75 400 (Bad Request) image:1 
GET https://myweb.com/_next/image?url=%2Fimages%2Fhello2.jpg&w=384&q=75 400 (Bad Request) image:1 
in local it's working fine, but in my hosting is error 400
@Asiatic Lion in local it's working fine, but in my hosting is error 400
try start the standalone build in local
@Ray try start the standalone build in local
Asiatic LionOP
its working fine, but in my cpanel found 400 bad request in the browser console when i open the web
ls standalone
ls standalone/.next
@Ray ls standalone ls standalone/.next
Asiatic LionOP
how do you start the server on the hosting?
@Ray how do you start the server on the hosting?
Asiatic LionOP
node .next/standalone/server.js
@Asiatic Lion node .next/standalone/server.js
could you open the network console and try to access the site and show a screenshot
open the image directly in the browser
@Ray open the image directly in the browser
Asiatic LionOP
@Asiatic Lion Click to see attachment
how did you render the image?
@Ray how did you render the image?
Asiatic LionOP
using Image from 'next/image'
what do you put it in src?
Asiatic LionOP
<Image
  src="/images/hello.png"
  alt="Hello"
  width={500}
  height={500}
  className="mx-auto max-w-[20rem] sm:max-w-full"
  priority
/>
@Ray can you open https://myweb.com/images/hello.png?
Asiatic LionOP
yes i found the image, and no error
but it's not optimized right?
do you have sharp installed?
Asiatic LionOP
yes
can you try this?
import hello from "/images/hello.png";

<Image
  src={hello}
  alt="Hello"
  width={500}
  height={500}
  className="mx-auto max-w-[20rem] sm:max-w-full"
  priority
/>
Asiatic LionOP
@Ray i found the image when i put the origin on the image url
https://myweb.com/_next/image?url=https://myweb.com/images/hello.jpg&w=640&q=75
Oh using basepath config right?
you using basePath in next.config.js?
@Ray you using basePath in next.config.js?
Asiatic LionOP
i will try
@Asiatic Lion i will try
no that doesn't help
Using custom image loader maybe?
@Asiatic Lion My hosting use apache
could you show the config?
@Ray could you show the config?
Asiatic LionOP
I couldn't, my cpanel is limited