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
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:
There are some options to deploy NextJS app in CPanel:
next export
to producing optimized frontend files.Specify your server file on that field.
You should run
next export
to make static html and js files inout
you can directly upload it to Cpanel as normal html websiteyou can run
npm run export
oryarn export
by addingthese in package.json
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/
All you really need to do is run
next export
and put the contents of theout
folder in the public_html folder or/var/www/html/
,/sites-available/
, etc, depending on setup.