Next.js Discord

Discord Forum

Error Build - App Router - cPanel

Unanswered
Asiatic Lion posted this in #help-forum
Open in Discord
Avatar
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

Avatar
@joulev try this: https://kdaws.com/learn/fixing-next-js-error-spawn-errno-11-on-cpanel-and-plesk-with-cloudlinux/
Avatar
Asiatic LionOP
i just tried this, but still error,
i am using cPanel and next 14.0.4 app router
Avatar
@Ray same error?
Avatar
Asiatic LionOP
yes
Avatar
@Asiatic Lion yes
Avatar
have you tried set cpus to 1?
cpus: 1
Avatar
@Ray have you tried set cpus to 1? `cpus: 1`
Avatar
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  ...
Avatar
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 
Avatar
@Ray how many cpu does your node have?
Avatar
Asiatic LionOP
$ nproc
8
Avatar
@Ray set this in `next.config.js` ts output: 'standalone'
Avatar
Asiatic LionOP
Yes, I have done it, and I encountered the errors above
Avatar
so the build process success? and you tried to start the server with node .next/standalone/server.js?
Avatar
@Ray so the build process success? and you tried to start the server with `node .next/standalone/server.js`?
Avatar
Asiatic LionOP
yes, build is success in local, but when i open the localhost:3000, css, js, images is not loaded
Avatar
yes because in standalone mode, you have to copy public and static folder manually
Avatar
@Ray yes because in standalone mode, you have to copy public and static folder manually
Avatar
Asiatic LionOP
cp ./public .next/standalone/
cp .next/static .next/standalone/.next/
to .next/standalone?
Avatar
@Asiatic Lion to `.next/standalone`?
Avatar
yes
Avatar
@Ray yes
Avatar
Asiatic LionOP
standalone solved thanks bro, now want to try up to cpanel
Avatar
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
Avatar
@Asiatic Lion in local it's working fine, but in my hosting is error 400
Avatar
try start the standalone build in local
Avatar
@Ray try start the standalone build in local
Avatar
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
Avatar
@Ray ls standalone ls standalone/.next
Avatar
Asiatic LionOP
Image
Image
Avatar
how do you start the server on the hosting?
Avatar
@Ray how do you start the server on the hosting?
Avatar
Asiatic LionOP
node .next/standalone/server.js
Avatar
@Asiatic Lion node .next/standalone/server.js
Avatar
could you open the network console and try to access the site and show a screenshot
Avatar
open the image directly in the browser
Avatar
@Ray open the image directly in the browser
Avatar
Asiatic LionOP
Image
Avatar
@Asiatic Lion Click to see attachment
Avatar
how did you render the image?
Avatar
@Ray how did you render the image?
Avatar
Asiatic LionOP
using Image from 'next/image'
Avatar
what do you put it in src?
Avatar
Asiatic LionOP
<Image
  src="/images/hello.png"
  alt="Hello"
  width={500}
  height={500}
  className="mx-auto max-w-[20rem] sm:max-w-full"
  priority
/>
Avatar
Avatar
@Ray can you open https://myweb.com/images/hello.png?
Avatar
Asiatic LionOP
yes i found the image, and no error
but it's not optimized right?
do you have sharp installed?
Avatar
Asiatic LionOP
yes
Avatar
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
/>
Avatar
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?
Avatar
you using basePath in next.config.js?
Avatar
@Ray you using basePath in next.config.js?
Avatar
Asiatic LionOP
i will try
Avatar
@Asiatic Lion i will try
Avatar
no that doesn't help
Using custom image loader maybe?
Avatar
@Asiatic Lion My hosting use apache
Avatar
could you show the config?
Avatar
@Ray could you show the config?
Avatar
Asiatic LionOP
I couldn't, my cpanel is limited