How to work with the Setup Node.js App plugin

The Setup Node.js App plugin in cPanel lets you create and manage Node.js applications on Namecheap Shared Hosting. This article describes the interface and the actions you can take with your applications.

To deploy an application from start to finish or fix common errors, see the How to host a Node.js app on Shared Hosting (cPanel) article.


Interface

To access the application, open cPanel >> Setup Node.js App.

The following interface will be displayed there:


For existing apps, you will see the following columns:

  • App URI: application URI including the domain name;
  • App Root Directory: root directory of the application;
  • Mode: can be production or development;
  • Status: started/stopped, displays whether an application is running or not and the version of the application;
  • Actions: allows you to start, restart, stop, edit, and remove a particular application.

There is a corresponding button to create a new application.


Create application

If you wish to create a new application, go to cPanel >> Setup Node.js App > CREATE APPLICATION:

On the page that appears, you will see the following fields:

Choose the following parameters:

  • Pick your Node.js version;
  • Set Application mode to Production for a live site (so it hides technical errors from visitors) or Development (when you need to see full error details in the browser).

    These settings are automatically reflected in the application startup file. For example, Production sets NODE_ENV=production.

  • Enter the Application root folder where your code will live (e.g., nodeapp).

    IMPORTANT: Do not use public_html as the Application root. Node.js apps cannot run from that folder.

  • Select the Application URL by choosing your sub/domain, plus an optional URI path.
  • Enter the Application startup file name. You can change this later to match your actual entry file.

    IMPORTANT: The name must match your entry script exactly, such as app.js or server.js.

  • If you wish to add environment variables, click Add Variable to specify a name and a value:

  • Click CREATE.

Once created, cPanel registers the application on the server and creates the Application root folder, with the Application startup file inside it:

The startup file contains a default test script:

You can open your application URL to confirm that the environment works:

Next, you can upload your files to the Application root folder and install the required packages. For step-by-step instructions, see How to host a Node.js app on Shared Hosting (cPanel).


Manage application

With the help of the Actions section, you can manage the application in the following way:


To start a stopped application, do the following:

1. Click the Start icon in the Actions column in the stopped application row:


2. Note that when an action is completed, the Start icon changes to the Stop icon.


To stop a started application, do the following:

1. Click the Stop icon in the Actions column in the started application row.

2. Note that when an action is completed the Stop icon changes to the Start icon.

To restart a started application, click the Restart icon in the Actions column in the started application row:



PLEASE NOTE: During the restart, it won’t be possible to perform any actions with the app.


To edit the application, open cPanel >> Setup Node.js App and click the Pencil icon in the Actions column in the respective application row:



The editing menu looks like the following:

Using this menu, you can manage the created application in the following ways:

  • Restarting the application;
  • Stopping the application;
  • Destroying the application ;
  • Changing the Node.js version (this version switch can take up to 5 minutes);
  • Changing the Application mode from Production to Development (vice versa);
  • Modifying the Application root;
  • Modifying the Application URL (specify in a field an HTTP/HTTPS link to the application);
  • Modifying the Application startup file (specify as NAME.js file);
  • Running NPM install command (click the Run NPM Install button to install the package(s) described in the package.json file);
  • Adding Environment variables;
To remove a started application, click the Bin icon in the Actions column in the respective application row: 


PLEASE NOTE: When this action is completed, the application will be removed from the Web Applications table and you should see a confirmation pop-up displayed on your screen. 


Enter the virtual environment of the application

If you need to enter the virtual environment (e.g., to install additional modules), you can do so via SSH:

  1. Enable SSH access using the Manage Shell cPanel menu;
  2. Find the highlighted command mentioned at the top of the application page in Setup Node.js App:

  3. Open the cPanel >> Terminal menu and run the command:

That's it! You're inside the virtual environment of your application.

Updated
Viewed
71499 times

Need help? We're always here for you.

notmyip