Running Node.js and NPM in cPanel depends largely on your hosting provider’s setup. Some offer built-in Node.js support, while others require SSH access. Here’s how to get started:
1. Check If Your Hosting Supports Node.js
-
Log into your cPanel.
-
Look for a Setup Node.js App feature under the Software or Advanced section.
-
If you don’t find it, contact your hosting provider to confirm whether Node.js is supported.
2. Option A: Use the “Setup Node.js App” Feature (If Available)
-
Log into cPanel.
-
Go to Setup Node.js App.
-
Click Create Application or + Create.
-
Choose your desired Node.js version.
-
Set the application root folder (e.g.,
~/my_node_app
). -
Specify the startup file (
app.js
orserver.js
). -
Use the built-in command line field to run:
to install dependencies.
-
Click Run App or Restart to start your Node.js app.
3. Option B: Use Terminal or SSH (If Node.js App Feature Not Available)
-
Check if Terminal is available in cPanel under Advanced.
-
If no Terminal, request SSH access from your hosting provider.
-
Connect via Terminal or SSH client (e.g., PuTTY).
-
Navigate to your project directory:
-
Run:
to install dependencies.
-
Run your scripts as needed:
-
For long-running apps, if allowed, install a process manager:
4. Upload Your Project Files
-
Upload your project folder (including
package.json
) via File Manager or FTP. -
Make sure all necessary files are present before running
npm install
.
Important Notes
-
Not all shared hosting supports persistent Node.js apps.
-
Always check your hosting plan’s resource limits and allowed features.
-
If unsure, ask your hosting provider for guidance on Node.js usage and permissions.
Conclusion
With proper Node.js support or SSH access, you can run npm install
and execute Node.js scripts on your cPanel server just like on your local machine. Use the Setup Node.js App feature when available for the easiest experience.