How to Creating a Node.js application with the Node.js Selector

Step 1: Log in to cPanel

  1. First, log in to your cPanel account using the login details provided by your hosting provider.
  2. Enter your cPanel username and password, then click Log in.

Step 2: Open the Node.js Selector

  1. After logging in to cPanel, use the search bar at the top of the dashboard.
  2. Search for: Setup Node.js App

Step 3: Click Create Application

  1. The Node.js Selector page will display your existing Node.js applications.
  2. To create a new application, click:
  3. Create Application
  4. You will now see the Node.js application configuration page.

Step 4: Select the Node.js Version

  1. Choose the Node.js version required by your application.
  2. For example: Node.js 20.x / Node.js 21.x / Node.js 22.x
  3. You should always select a Node.js version that is compatible with your project and its dependencies.

Step 5: Select Application Mode

  1. Next, select the application mode.
  2. You will normally see two options: 1. Development , 2. Production
  3. For a live website or application, select: Production
  4. Use Development only while testing or debugging your application.

Step 6: Configure the Application Root

  1. The Application Root is the folder where your Node.js application files will be stored.
  2. For example: nodeapp
  3. cPanel may then create a directory similar to: /home/cpanelusername/nodeapp
  4. Do not enter the complete /home/username/ path unless your hosting panel specifically requires it.
  5. Application startup file : app.js

Step 7: Create the Node.js Application

  1. After completing all the required fields, review your configuration.
  2. Example configuration:
SettingExample
Node.js VersionNode.js 20
Application ModeProduction
Application Rootnodeapp
Application URLapp.example.com
Startup Fileapp.js


Click: CREATE

cPanel will create the Node.js environment for your application.


The application starts automatically. To view a test page for the application, click OPEN:

Now that a working application is installed, you can enhance the environment with the package.json settings file and the npm package manager. To do this, follow the next two procedures.

Step 8: Create the package.json file

  1. To create the package.json file, follow these steps:
  2. On the Tools page, in the Files section, click File Manager:
  1. In the left hand column of File Manager, click the text of the application root folder: Click +File to create a new file:
  2. In the New File dialog box, type the filename package.json, and then click Create New File:

Right-click or secondary click on the package.json file in the right-hand column of File Manager and then click Edit. An edit dialog box appears:

  1. In the Edit dialog box, click OK.
  2. Type 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 Save Changes to save the file:


Step 9: Install npm

To install npm, follow these steps:

  1. On the Tools page, in the Software section, click Setup Node.js App:
  2. In the Actions column of the Web Applications list, click the pencil icon to edit the application:

Click Run NPM Install

The NPM installation runs and displays a success indicator when complete:

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *