How to run a Node.js app in cPanel
- Open "Setup Node.js App" (group "Software").
- Click "CREATE APPLICATION".

- "Node.js version" - pick a recent LTS version.
- "Application mode" - Production for a live site, Development for debugging.
- "Application root" - the code folder, for example
nodeapp. Do not put the code in public_html. - "Application URL" - the domain and path where the app opens. An empty path means the whole domain.
- "Application startup file" - the main file, for example
app.js. - Click "CREATE".

The panel creates the folder, a virtual environment and a test app.js. Upload your code and package.json to the folder.
- Open the app in the list (pencil icon).
- Click "Run NPM Install" to install dependencies from package.json.
- Click "RESTART".

The app must not listen on port 80 or 3000 itself: the web server starts it through Passenger. Use the port from process.env.PORT - in Express that is app.listen(process.env.PORT).
const express = require('express');
const app = express();
app.get('/', (req, res) => res.send('Hello from Node.js'));
app.listen(process.env.PORT);Click "RESTART" after every code change. Environment variables (API keys and so on) are set under "Environment variables" on the same page.