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
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
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
Ray
try set it to 2?
how many cpu does your node have?
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 
$ nproc
8
Avatar
Ray
set this in next.config.js
output: 'standalone'
Avatar
Asiatic LionOP
Yes, I have done it, and I encountered the errors above
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
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
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
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
Avatar
Ray
could you show a screenshot of the standalone folder
ls standalone
ls standalone/.next
Avatar
Asiatic LionOP
Image
Image
Avatar
Ray
how do you start the server on the hosting?
Avatar
Asiatic LionOP
node .next/standalone/server.js
Avatar
Ray
could you open the network console and try to access the site and show a screenshot
Avatar
Asiatic LionOP
i found this error
just for image 400 bad request
css and js it's work
Avatar
Ray
open the image directly in the browser
Avatar
Asiatic LionOP
Image
Avatar
Ray
how did you render the image?
Avatar
Asiatic LionOP
using Image from 'next/image'
Avatar
Ray
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
Ray
Avatar
Asiatic LionOP
yes i found the image, and no error
but it's not optimized right?
Avatar
Ray
this link no
do you have sharp installed?
Avatar
Asiatic LionOP
yes
Avatar
Ray
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
Ray
you using basePath in next.config.js?
Avatar
Asiatic LionOP
i will try
Avatar
Ray
no that doesn't help
Avatar
Asiatic LionOP
My hosting use apache
Using custom image loader maybe?
Avatar
Ray
could you show the config?
Avatar
Asiatic LionOP
I couldn't, my cpanel is limited