How to Create a Node.js Application with the Node.js Selector

Node.js lets you run JavaScript on the server, and it is used for APIs, chat apps, dashboards and many modern web frameworks. On shared hosting you cannot simply run node app.js in a terminal and leave it running. Instead, many cPanel servers that run CloudLinux include the Node.js Selector, shown in cPanel as Setup Node.js App.

The Node.js Selector lets you choose a Node.js version, set the folder and URL for your app, install npm packages and start, stop or restart the application from cPanel. Behind the scenes the app is served through Phusion Passenger, so it starts automatically when someone visits its URL.

Before You Start

  • Your hosting plan must include Setup Node.js App. It is a CloudLinux feature, so not every cPanel host offers it.
  • Decide which domain or subdomain will serve the app, for example app.example.com. Creating a dedicated subdomain first keeps the Node.js app separate from a WordPress or PHP site.
  • Know which Node.js version your project needs (check the engines field in its package.json, if present).
  • Have your application code ready, and do not upload a node_modules folder. The selector installs packages for you.

Steps to Create a Node.js Application

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
  3. It is normally listed in the Software section. Menu names can vary slightly by host and theme.

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: Create Application
  3. 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.

Even-numbered releases become long-term support (LTS) versions, which are usually the best choice for production sites. The list you see depends on what your host has installed.

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.

The selected mode is passed to your app as the NODE_ENV environment variable. Many frameworks, such as Express, enable caching and hide detailed error messages when NODE_ENV is production.

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

Keep the application root outside public_html so your source code and configuration files cannot be downloaded directly. Also choose the Application URL (the domain or subdomain plus an optional path) where the app will be available.

Step 7: Create the Node.js Application

After completing all the required fields, review your configuration. 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

To create the package.json file, follow these steps:

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

Right-click (or secondary click) 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. If your app uses packages such as Express, list them in a "dependencies" section of this file so npm knows what to install.

Step 9: Install npm Packages

To install npm packages, 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. After installing packages or changing your code, click Restart on the same page so the app loads the changes.

The edit page also shows a command for entering the app’s virtual environment, similar to source /home/username/nodevenv/nodeapp/20/bin/activate && cd /home/username/nodeapp. If your plan includes SSH or the cPanel Terminal, run that command first and you can then use npm and node with the selected version.

Common Problems and How to Fix Them

Error about a node_modules folder in the application root

The selector stores packages in a separate virtual environment and links them into your app as node_modules. If you uploaded your own node_modules folder, delete it from the application root and click Run NPM Install again.

The app shows an error page or “Incomplete response received from application”

Usually the app crashed during start-up. Check that the startup file name matches exactly (it is case-sensitive), that all packages are installed, and review the log file path set in the application settings or the stderr.log file in the application root, if your host creates one.

The app listens on the wrong port

Passenger tells your application which port or socket to use. Start your server with app.listen(process.env.PORT || 3000) instead of hard-coding a port number.

Changes do not appear

Node.js keeps code in memory. Click Restart in Setup Node.js App after every code or configuration change.

Tips and Best Practices

  • Use a subdomain for each Node.js app to keep things organised.
  • Store API keys and passwords as Environment variables in the application settings instead of hard-coding them.
  • Upload package-lock.json along with package.json so the same package versions are installed on the server.
  • Keep Production mode for live sites and only switch to Development while troubleshooting.
  • Shared hosting has CPU and memory limits, so very heavy or long-running background tasks may need a VPS.

Frequently Asked Questions

Can I change the Node.js version later?

Yes. Edit the application, choose another version, save and run NPM Install again, because some packages must be rebuilt for each Node.js version.

Do I need SSH access to run a Node.js app?

No. You can create the app, edit files and run npm install entirely from cPanel. SSH is helpful but optional.

Can I run a Node.js app and WordPress on the same domain?

It is possible by using a sub-path as the Application URL, but a separate subdomain is simpler and avoids conflicts.

Conclusion

The Node.js Selector makes it straightforward to host a Node.js application on cPanel: pick a version, set the application root, URL and startup file, add a package.json, install dependencies and restart. With the troubleshooting tips above, you can get most apps running without needing a VPS.

Related Tutorials