cPanel

How to run a Node.js on Ecenica Hosting

This guide shows you how to set up, configure, and run a Node.js application on your Ecenica hosting account.


Prerequisites

Before you begin, ensure you have:

  • An Ecenica hosting plan that supports Node.js (check your plan details in the Ecenica Dashboard)
  • Your Node.js project files ready to upload
  • Access to cPanel

Not sure if your plan supports Node.js? Log in to the Ecenica Dashboard and check your hosting plan details, or contact Ecenica support to confirm.


Understanding Node.js on Ecenica Hosting

Ecenica hosting uses Setup Node.js App in cPanel to manage Node.js applications. This tool:

  • Installs Node.js modules automatically
  • Manages environment variables
  • Handles application restarts
  • Creates a virtual environment for each app

Important: You cannot run npm commands directly from the command line on Ecenica shared hosting. All Node.js management must be done through the Setup Node.js App interface.


Step 1: Prepare Your Application Locally

Before uploading to your Ecenica hosting, you should build your application on your local machine.

Build Your App Locally

  1. On your local computer, navigate to your Node.js project
  2. Run your build command (e.g., npm run build)
  3. Ensure your dist or build folder is generated

Why build locally? Building on the server can hit memory limits and fail. Building locally is faster and more reliable, especially on Ecenica shared hosting where resources are balanced across multiple accounts.

What to Upload

Upload these files to your Ecenica hosting:

  • All application files (.js, .json, etc.)
  • Your package.json file
  • Your dist or build folder (if applicable)
  • Any static assets (images, CSS, etc.)

Do NOT upload:

  • node_modules folder (cPanel will create this automatically)
  • .git folder (unless needed)
  • Large development files

Step 2: Upload Your Application Files

  1. Log in to cPanel through the Ecenica Dashboard – See: Where do I login to my hosting control panel?
  2. Open File Manager
  3. Create a new folder, mynodeapp and then another folder app within it.
  4. Navigate to your new app directory.
  5. Click Upload
  6. Upload all your application files plus the dist folder to this directory. Tip: the fastest way is to create a zip file, upload and then extract it via File Manager.

Step 3: Create Your Node.js Application in cPanel

  1. In your Ecenica cPanel, click Setup Node.js App
  2. Click Create Application
  3. Fill in the application details:

Node.js version: Choose your required version (e.g., 24.x, 22.x)

  • Ecenica regularly updates available Node.js versions

Application mode:

  • Production (recommended for live sites on Ecenica hosting)
  • Development (for testing)

Application root: Enter the path to your application folder

  • Path is relative to /home/username/
  • Example: mynodeapp/app

Application URL: The domain or subdomain where your app will run

  • Example: https://yourdomain.com or https://app.yourdomain.com
  • Important: Each URL can only run ONE Node.js app. You cannot run two apps on the same URL.

Application startup file: Your main entry file

  • Example: server.js or app.js or dist/index.js
  1. Click Create

cPanel will create your application and set up the environment on your Ecenica hosting account.


Step 4: Install Node Modules

After creating your application:

  1. In Setup Node.js App, find your application in the list
  2. Click Run NPM Install

cPanel will install all dependencies listed in your package.json on your Ecenica hosting space.

Troubleshooting: node_modules Error

Error message:

“Cloudlinux NodeJS Selector demands to store node modules for application in separate folder (virtual environment) pointed by symlink called ‘node_modules’. That’s why application should not contain folder/file with such name in application root.”

Solution:

  1. Check if you have a node_modules folder in your application root
  2. If it exists, delete it or rename it
  3. Click Run NPM Install again

cPanel creates its own node_modules symlink on your Ecenica hosting, so you shouldn’t upload this folder.


Step 5: Start Your Application

  1. In Setup Node.js App, find your application
  2. Click Start App or ensure the toggle is set to Running

Your Node.js application is now live on your Ecenica hosting at the URL you specified.


Managing Environment Variables

Environment variables let you store sensitive information (like API keys, database passwords, SMTP credentials) outside your code files.

How to Add Environment Variables

  1. In Setup Node.js App, click Edit on your application
  2. Scroll to Environment Variables
  3. Click Add Variable
  4. Enter:
    • Key: Variable name (e.g., SMTP_PASSWORD)
    • Value: Variable value (e.g., your-password-here)
  5. Click Save

Important: You must click Save after adding variables, or they won’t be applied.

Do Environment Variables Override .env Files?

Yes. Variables set in Setup Node.js App override any .env files in your application.

Priority order:

  1. Variables in Setup Node.js App (highest priority)
  2. Variables in your .env file
  3. Default values in your code

Do I Need to Restart After Changing Variables?

No. Changes to environment variables in Setup Node.js App are applied automatically. You do NOT need to restart your application.

However, if you edit .env files directly on the server, you DO need to restart for changes to take effect.

Where Are Environment Variables Stored?

cPanel stores environment variables in:

./.cl.selector/node-selector.json

Do not edit this file manually. Always use the Setup Node.js App interface in your Ecenica cPanel.


Restarting Your Application

You need to restart your application when:

  • You’ve edited .env files directly (not through cPanel)
  • You’ve made code changes that require a restart
  • Your application has crashed or stopped responding

How to Restart

  1. Go to Setup Node.js App in your Ecenica cPanel
  2. Find your application
  3. Click Restart

Your application will stop and start again, picking up any changes.


Running NPM Scripts

You can run scripts defined in your package.json from Ecenica cPanel.

How to Run a Script

  1. In Setup Node.js App, click Edit on your application
  2. Scroll to Run JS Script
  3. Enter the script name (e.g., build, test, migrate)
  4. Click Run

This executes the corresponding script from your package.json.

Example

If your package.json has:

{
"scripts": {
"build": "webpack –mode production",
"migrate": "node migrate.js"
}
}

You can run build or migrate through the Run JS Script feature.

Troubleshooting: Build Script Memory Errors

Error: Running build script fails with error code 1 and memory limit warnings.

Solution: Do NOT build on the server. Build your application locally and upload the built files (e.g., dist folder). Ecenica shared hosting has resource limits designed to keep the service stable for all customers, which often aren’t sufficient for intensive build processes.


Uploading Changes and Updates

How to Upload Code Changes

  1. Make changes to your application locally
  2. Upload the changed files via File Manager in Ecenica cPanel or FTP
  3. Upload to your application root directory

Changes are applied automatically. You do NOT need to restart your application for most code changes.

Exception: If you change environment variables in .env files, restart your application.


Changing Application Settings

How to Change the Application Name

  1. Rename your application directory using File Manager in Ecenica cPanel
  2. Go to Setup Node.js App
  3. Click Edit on your application
  4. Update the Application root path to match the new directory name
  5. Click Save

How to Change the Application Root

  1. Go to Setup Node.js App in your Ecenica cPanel
  2. Click Edit on your application
  3. Change the Application root path
  4. Click Save

cPanel will automatically move your application files to the new location on your Ecenica hosting.


Email Configuration for Node.js Apps

If your Node.js application sends emails (e.g., contact forms, notifications), use these Ecenica SMTP settings:

SMTP Server: mail.yourdomain.com
SMTP Port: 465
Security: SSL/TLS (Secure)
Username: Your Ecenica email address
Password: Your Ecenica email password

Store these in environment variables:

  • SMTP_HOST=mail.yourdomain.com
  • SMTP_PORT=465
  • SMTP_SECURE=true
  • SMTP_USER=your-email@yourdomain.com
  • SMTP_PASS=your-password

Note: You can create email accounts for your domain in Ecenica cPanel under Email Accounts.


Staging Your Node.js Application

To test changes before deploying to your live site on Ecenica hosting:

Option 1: Use a Subdomain

  1. Create a subdomain in Ecenica cPanel (e.g., staging.yourdomain.com)
  2. Set up a separate Node.js app in Setup Node.js App
  3. Point the staging app to a different directory (e.g., public_html/mynodeapp-staging)
  4. Test changes on the staging subdomain before deploying to production

Option 2: Use a Different Directory

  1. Clone your application to a new directory on your Ecenica hosting
  2. Create a second Node.js app pointing to the new directory
  3. Use a different URL (subdomain or addon domain)

Understanding the nodevenv Directory

If you see a nodevenv directory in your Ecenica File Manager:

What is it? This is where your Node.js applications are compiled and stored by cPanel on your Ecenica hosting.

Can I delete it? No. Do not delete or modify this directory. Deleting it will break your Node.js applications.


Troubleshooting Common Issues

“bash: npm: command not found” When Using SSH

Problem: You tried to run npm from the command line and got an error.

Solution: You cannot run npm directly from SSH on Ecenica shared hosting. All Node.js management must be done through the Setup Node.js App interface in cPanel.

If you need command-line npm access, consider upgrading to Ecenica Managed VPS where you have full control.

Application Won’t Start

Check these:

  1. Is the startup file path correct? (e.g., server.js or dist/index.js)
  2. Did you run NPM Install to install dependencies?
  3. Are there any errors in the application logs?
  4. Is your application trying to use a port that’s already in use?

View logs:

  1. In Setup Node.js App, click Edit on your application
  2. Scroll to Application Logs
  3. Check for error messages

Application Keeps Crashing

Common causes:

  • Uncaught exceptions in your code
  • Missing environment variables
  • Port conflicts
  • Memory limits exceeded on Ecenica shared hosting

Solutions:

  1. Check application logs for error messages
  2. Verify all required environment variables are set
  3. Add error handling to your code
  4. Ensure your app uses the port provided by the environment
  5. If you’re consistently hitting resource limits, consider upgrading to Ecenica Managed VPS for dedicated resources

Changes Aren’t Showing Up

Solutions:

  1. Clear your browser cache
  2. Restart your application in Ecenica cPanel
  3. Check you uploaded files to the correct directory
  4. Verify the file permissions are correct (usually 644 for files, 755 for directories)

Starting Over: Destroying and Recreating Your App

If your application is severely broken and you want to start fresh:

How to Destroy and Recreate

  1. Go to Setup Node.js App in your Ecenica cPanel
  2. Find your application
  3. Click Destroy or Delete
  4. Confirm deletion

This removes:

  • The application configuration
  • The virtual environment
  • The node_modules symlink

It does NOT delete your application files, so you can recreate the app using the same files.

  1. Follow the setup steps again from Step 3

Frequently Asked Questions

Can I run multiple Node.js apps on the same domain?
No. Each URL can only run one Node.js application on Ecenica hosting. To run multiple apps, use subdomains or different addon domains.

What Node.js versions are supported?
Check the available versions in the Setup Node.js App interface in your Ecenica cPanel. Ecenica regularly updates supported versions to include the latest stable releases.

Can I use TypeScript?
Yes, but you must compile TypeScript to JavaScript locally before uploading to your Ecenica hosting. Upload the compiled JavaScript files.

Does my app run 24/7?
Yes, once started, your Node.js app runs continuously on Ecenica hosting unless stopped manually or if there’s a server restart.

How much memory can my Node.js app use?
This depends on your Ecenica hosting plan. Shared hosting has resource limits to ensure fair usage across all customers. If you need more resources, consider upgrading to Ecenica Managed VPS.

Can I use npm packages?
Yes. List them in your package.json and they’ll be installed when you click Run NPM Install in Ecenica cPanel.

What happens if I exceed resource limits?
Your application may be temporarily suspended or slow down. You’ll receive a notification from Ecenica. Consider optimising your code or upgrading your plan.

Can I use WebSockets?
Support for WebSockets varies by Ecenica hosting plan. Contact Ecenica support to confirm if your plan supports WebSockets.

How do I secure my Node.js app on Ecenica hosting?

  • Use environment variables for sensitive data
  • Keep dependencies updated
  • Use HTTPS (SSL certificates are available free with Ecenica hosting)
  • Implement proper authentication
  • Validate all user inputs

What if I need more control over Node.js?
If you need root access, custom Node.js versions, or more resources, consider upgrading to Ecenica Managed VPS where you have full server control.


Upgrading to Ecenica Managed VPS for Node.js

If you’re hitting limitations on shared hosting, Ecenica Managed VPS offers:

  • Full root access – Install any Node.js version and run npm from the command line
  • Dedicated resources – No shared resource limits
  • More memory – Run memory-intensive builds and applications
  • Multiple apps – Run as many Node.js applications as you need
  • WebSocket support – Full support for real-time applications
  • Process managers – Use PM2 or other process managers
  • Custom configurations – Complete control over your server environment

Contact Ecenica support to discuss upgrading to Managed VPS.


Need Help?

If you’re having trouble setting up your Node.js application or have questions not covered in this guide, contact Ecenica support and our technical team will be happy to assist you.

For complex Node.js applications or if you’re unsure whether your project will work on Ecenica shared hosting, reach out before you begin—we can advise on the best hosting solution for your needs.

Was this guide helpful?

Need help with this?

Open a ticket and link to this guide so our team can see what you have tried.

View support tickets

Power your business with Ecenica Hosting

Built for WordPress and serious websites. Fast, secure and supported by real people in the UK.

Ecenica hosting services represented by a connected red route across London