https://confluence2.cpanel.net/display/CKB/How+to+Install+a+Node.js+Application
https://codeburst.io/installing-reactjs-and-creating-your-first-application-d437706498ed
Use the Node JS with full path as: # /opt/cpanel/ea-nodejs16/bin/node -v v16.20.2 Official cPanel documentation: https://docs.cpanel.net/knowledge-base/web-services/how-to-install-a-node.js-application/
How to install a Node.js application
Timothy Haines
- 5 months ago
- Updated
Follow
Not yet followed by anyone
Introduction
This article discusses how to install a Node.js application on a cPanel account.
Procedure
To install an application:
- Log in to the server as the cPanel user via SSH or ‘Terminal‘ in cPanel.
- Create the application’s directory relative to the user’s home directory.
mkdir nodejsapp - Change to the application’s directory.
cd nodejsapp - Create the
app.js
file with a text editor.
Please note we strongly recommend that you create the file with this exact name because Passenger searches for this filename when it executes. - Add the application’s configuration to the
app.js
file. This will resemble the following example:
const http = require(‘http’) const hostname = ‘127.0.0.1’; const port = 3000; const server = http.createServer((req, res) => { res.statusCode = 200; res.setHeader(‘Content-Type’, ‘text/plain’); res.end(‘Hello World! NodeJS \n’); }); server.listen(port, hostname, () => { console.log(`Server running at http://${hostname}:${port}/`); }); - Save the changes.
- Close the text editor.
Please note after installing that application, it must be registered in cPanel with “Application Manager.”
From: https://support.cpanel.net/hc/en-us/articles/6840609038103-How-to-install-a-Node-js-application