Knowledgebase

Node.js Application Setup Guide on Cpanel Print

  • 0

Setting Up a Node.js Application via cPanel

1. Create a New Application

  • Log in to your cPanel account.

  • Scroll to the SOFTWARE section and click on Setup Node.js App.

    

  • On the Node.js page, click Create Application.

    

  • Fill in the following:

    • Node.js version – Select your preferred version.

    • Application mode – Choose between Development or Production.

    • Application root – Folder where your app files will reside (e.g., /app).

    • Application URL – The web address to access your app (e.g., yourdomain.com/app).

    • Startup file – Entry point for the app (commonly app.js or index.js).

          

  • Click Create.

  • After creating the app, you may see a message asking for a package.json file.

    

  • You can click Open to see a test page or Cancel to proceed.

2. Create package.json File

  • Go back to cPanel > File Manager.

     

  • Open the folder you set as your Application Root.

     

  • Click +File and name it package.json.

     

  • Right-click the file and choose Edit, then paste the following

    

{ "name": "app", "version": "1.0.0", "description": "Node.js App on Prabhu Host", "main": "app.js", "scripts": { "start": "node app.js" }, "author": "", "license": "ISC" }
  1. Click Save Changes, then Close.

3. Install NPM Packages

  • Go back to Setup Node.js App in cPanel.

     

  • Click the pencil (edit) icon beside your application.

     

  • Click Run NPM Install to install dependencies from package.json.

To install more packages or run commands, use SSH and activate your app’s virtual environment (see below).

Setting Up Node.js Using SSH (Advanced Users)

If you prefer working through the terminal, follow these steps to configure your app via SSH.

1. Connect to SSH

  1. Login via SSH using your hosting account credentials.

2. Create Application Using CloudLinux Selector

cloudlinux-selector create --json --interpreter nodejs --version 18 --app-root myapp --domain yourdomain.com --app-uri app

3. Navigate to App Directory

cd ~/app

4. Create package.json

Use your editor (e.g., vi, nano):

vi package.json

Paste the following content:

{ "name": "app", "version": "1.0.0", "description": "My Prabhu Host App", "main": "app.js", "scripts": { "start": "node app.js" }, "author": "", "license": "ISC" }

Save and exit (for vi: press Esc, then type :wq and press Enter).

5. Install Node Modules

cloudlinux-selector install-modules --json --interpreter nodejs --user yourcpanelusername --app-root app

6. Activate Virtual Environment

source /home/clusterc/nodevenv/samnode/16/bin/activate && cd /home/clusterc/samnode

You're now inside the isolated environment and can install packages using:

npm install express

You're All Set!

Your Node.js app is now up and running on Prabhu Host using either the easy cPanel GUI or the powerful command line. If you encounter any issues, don’t hesitate to reach out to our 24/7 Support Team we’re always here to help!


Was this answer helpful?
« Back