skip to Main Content

I am trying to deploy next js app on cPanel. I have installed node and npm on it.
How can I deploy the next js app on this set up?

I am getting the following error while trying to build the app on cpanel terminal:

Unhandled rejection TypeError: child.send is not a function

5

Answers


  1. You’ll need root privileges. If you’ve got them you can remote into your server via SSH and run the npm commands there. Then it should work. I.e, from console:

    ssh user@serverip
    cd /path/to/appdirectory
    npm run start
    
    Login or Signup to reply.
  2. There are some options to deploy NextJS app in CPanel:

    1. You just deploy serverless app (without NodeJS) in CPanel. NextJS has provided a syntax like next export to producing optimized frontend files.
    2. New version of CPanel already has entry point for your nodejs application:
      Entry point of NodeJS app in CPanel Specify your server file on that field.
    Login or Signup to reply.
  3. You should run next export to make static html and js files in out you can directly upload it to Cpanel as normal html website
    you can run npm run export or yarn export by adding

    "scripts": {
        "dev": "next",
        "build": "next build",
        "start": "next start",
        "export": "next export"
      },
    

    these in package.json

    Login or Signup to reply.
  4. Next.js applications should run fine on a web hosting provider using cPanel, but running the default next.js server tends to exceed process count and memory quotas applied by those types of providers.

    However you can make hosting next.js apps work if you build a production version of your app elsewhere and then use a custom server to call your next.js app to handle incoming requests.

    I describe the process to deploy a very basic application as a subsite on my website here – https://www.watfordconsulting.com/2021/02/08/deploy-next-js-applications-to-a-cpanel-web-host/

    Login or Signup to reply.
  5. All you really need to do is run next export and put the contents of the out folder in the public_html folder or /var/www/html/, /sites-available/, etc, depending on setup.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search