skip to Main Content

I am trying to deploy a react app and a node server to my domain http://cv-devlabs.com/ with cPanel but failing to run. Most of the time I’m getting a "server responded with the 404 error".

I have tried methods from "hosting react app and express server cpanel" and "How to deploy a react app on cPanel?" and failed at both. I’m assuming I did something wrong here.

My file structure is:

Root-Folder–
-client
–build
–node_modules
–public
–package.json(client)(content added below)
-.gitignore
-package.json(server)(content added below)
-procfile
-server.js

Package.json (client)

    "name": "client",
  "homepage": "http://cv-devlabs.com/vidci-vid2/",
  "version": "0.1.0",
  "private": true,
  "proxy": "http://localhost:8000",

Package.json(server)

{
  "name": "vidci-vid",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "dependencies": {
    "dotenv": "^8.2.0",
    "express": "^4.17.1",
    "socket.io": "^2.3.0"
  },
  "scripts": {
    "start": "PROD=true node server.js",
    "postinstall": "cd ./client && yarn"
  }
}

This is working fine on Heroku but on cPanel, it’s not. The whole project can be found at https://github.com/ConsultVerraton/vidci-vid.git

Thanks to anyone who can help and thanks to anyone who can try. Do let me know if more information is needed.

Thanks

3

Answers


  1. You cannot host a node.js app in most providers working with cpanel. If you want to host a node.js app you should deploy it on a vps. You can follow this tutorial for example:
    https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-16-04

    But in these cpanel providers, you could host a static react app (for example an app build with create-react-app). This kind of app does not need node.js at runtime. So you can build the assets and push them to your cpanel host.

    You can follow this tutorial:
    https://dev.to/crishanks/deploy-host-your-react-app-with-cpanel-in-under-5-minutes-4mf6

    Login or Signup to reply.
  2. Yes you can, but it depend if the host provider allow it.

    I’m actually running a express server on a cPanel account.

    I didn’t found the official documentation of cPanel but this is a pretty good one: How to create a Node.js application with cPanel using the Node.js Selector

    If your looking to do it in command line, this the official documentation from cPanel :How to Install a Node.js Application.

    Login or Signup to reply.
  3. I don’t know about react but for anyone who wants to know how to deploy node js app to Cpanel this is a good source for him, this explains thoroughly how to deploy node js app to cpanel please check this

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