Deploy a Node.js Application

Learn how to build, configure, and deploy a production-ready Node.js application to CloudNexus infrastructure in under 5 minutes.

📖 6 min read 🕒 Last updated: Oct 24, 2025 ⚡ v2.4.1

Prerequisites

  • Node.js v18+ and npm/yarn installed locally
  • A working Node.js application with package.json
  • CloudNexus account with an active project
  • Git installed and project version controlled

1Prepare Your Project Structure

CloudNexus automatically detects Node.js applications. Ensure your project has a valid package.json with a start script pointing to your entry file.

JSON
{
  "name": "my-node-app",
  "version": "1.0.0",
  "scripts": {
    "start": "node dist/server.js",
    "build": "tsc"
  },
  "engines": {
    "node": ">= 18.0.0"
  }
}
ℹ️
Note on Build Steps

If your app requires a build step (e.g., TypeScript, Next.js, webpack), CloudNexus will automatically run npm run build before starting the server.

2Install & Authenticate CLI

Use the CloudNexus CLI to manage deployments from your terminal. Install it globally via npm:

Bash
npm install -g cnxs-cli

Authenticate using your access token from the dashboard:

Bash
cnxs login
⚠️
Token Security

Never commit your access token to version control. Use environment variables or secret managers in CI/CD pipelines.

3Configure Deployment

Create a cloudnexus.config.js in your project root to customize build and runtime behavior:

JavaScript
module.exports = {
  framework: "node",
  buildCommand: "npm run build",
  startCommand: "npm start",
  outputDirectory: ".",
  env: {
    NODE_ENV: "production",
    PORT: 3000
  },
  scaling: {
    minReplicas: 2,
    maxReplicas: 10,
    strategy: "auto"
  }
};
Property Description Default
buildCommand Command to run before starting npm run build
startCommand Command to run your server npm start
scaling.strategy Auto, fixed, or custom "auto"

4Deploy to CloudNexus

Once configured, push your application with a single command:

Bash
cnxs deploy --project my-node-app --region us-east-1

The CLI will bundle your app, upload it to the nearest edge node, and provision the runtime. You'll see real-time logs:

Terminal
✓ Project validated
✓ Building dependencies...
✓ Optimizing for production...
✓ Deploying to us-east-1...
✓ DNS propagation complete

🚀 Application live: https://my-node-app.cloudnexus.app
Deployment Complete

Your Node.js app is now live with automatic SSL, global CDN caching, and zero-downtime deployments enabled by default.

5Manage Environment Variables

Securely inject secrets and configuration without modifying your codebase:

Bash
cnxs env set DATABASE_URL "postgresql://..." --project my-node-app
cnxs env set JWT_SECRET "your-super-secret-key" --project my-node-app

Variables are encrypted at rest and automatically injected into the runtime. Restart your deployment to apply changes:

Bash
cnxs restart --project my-node-app

Troubleshooting

Build fails with memory issues

Node.js builds can exceed default limits. Increase build memory in your config:

JavaScript
{
  build: { memory: "4GB" }
}

Application exits immediately

Ensure your server binds to 0.0.0.0 and reads the PORT environment variable. CloudNexus dynamically assigns ports.

Logs show "Cannot find module"

Check your package.json dependencies. Native modules may require the node-gyp build chain. Enable it via cnxs env set BUILD_NATIVE=1.

Frequently Asked Questions

Does CloudNexus support TypeScript?

Yes. Add a tsconfig.json and npm run build step. CloudNexus detects and compiles TS automatically.

Can I deploy from GitHub/GitLab?

Absolutely. Connect your repository in the dashboard for automatic deployments on every push to main.

What happens during a deployment?

We use blue-green deployment. New instances spin up, pass health checks, and traffic shifts seamlessly. Zero downtime.