In this tutorial, you'll learn how to easily set up Node.js applications within the cPanel graphical interface or from the command line. HostBend's infrastructure supports Node.js right out of the box.

Using the cPanel Interface
Create the Application

Log in to cPanel.
In the Software section of cPanel, click on the Setup Node.js App icon.

On the Node..js selector page, click on the Create Application button to start the application setup.

Fill in the required fields on the application setup form.

Node.js Version - Select your preferred Node.js version from the drop-down list.
Application Mode - Choose Development or Production from the drop-down list. You can choose Development initially and change it to Production later.
Application Root - The file system location for the application files. The entry will be appended to /home/username to form the complete path to the application files in the cPanel home directory.
Application URL - The public URL to your application.
Application Startup File - The initial file that will be processed when launching the application.

When the form is complete, click the Create button.
After the application is created, an information box is displayed advising that the package.json is required to continue.

The application will launch and display a test page. If you wish to see the test page, click the Open button.

Click the Cancel button to continue.

Now that a working application is installed, the environment can be enhanced with the package.json settings file and the NPM package manager. To install package.json and NPM, follow the steps in the next two sections.

Creating the package.json File
Go back to cPanel's dashboard. In the Files section, click the File Manager icon to open the File Manager.

In the left-hand column of the File Manager, click the text of the application root folder.

Click the +File button to create a new file.

In the New File dialog box, enter the file name package.json and then click the Create New File button.

Once the file is created, right-click or secondary click on the package.json file in the right-hand column of the File Manager and then click Edit. An Edit dialog box is displayed.

In the Edit dialog box, click the OK button and enter the following text in the editor screen:

"name": "app",
"version": "1.0.0",
"description": "My App",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"author": "",
"license": "ISC"

Click the Save Changes button to save the file.
Click the Close button to close the editor.

Install NPM
In the Software section of cPanel's dashboard, click on the Setup Node.js App icon.

In the Actions column of the Web Applications list, click the pencil icon to edit the application.

Click the Run NPM Install button.

The NPM installation runs and presents a success indicator when completed.

To install packages with NPM and do other command-line tasks related to the application, log in via SSH and enter the virtual environment for the application using the command line shown in the information box at the top of the application setup page.

Using the Command Line Interface
If you're familiar with using SSH, you may find the command line interface faster and easier than using the cPanel install interface.

To setup a Node.js application from the command line, follow these steps:
Connect to your account via SSH.
Create the Node.js application with the following command:

cloudlinux-selector create --json --interpreter nodejs --version 11 --app-root app --domain --app-uri app

Once you're inside of your account's home directory, change to the application directory:

cd ~/app

Open your preferred text editor and create the package.json file. In this example, we're using the vi text editor.

vi package.json

Press I to change to insert mode and paste the following text into the editor.

"name": "app",
"version": "1.0.0",
"description": "My App",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"author": "",
"license": "ISC"

Press the ESC key followed by the : to enter command mode, then press the x key followed by Enter to save and exit the vi editor.

Install NPM by entering the following command:

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

To install packages with NPM and do other command-line tasks related to the application, log in via SSH and enter the virtual environment for the application using the command:

source /home/example/nodevenv/app/11/bin/activate && cd /home/example/app

That's a wrap! Now you know how to set up Node.js applications in cPanel and the command-line interface.
Was this article helpful?
Thank you!