Building a Node.js app is one thing; getting it online reliably is another. You do not always need to manage your own server. Many hosting plans now let you deploy a Node.js app from a zip file or a GitHub repository, build it automatically and run it for you. This guide shows how to prepare and deploy your project step by step.
What you need before you deploy a Node.js app
- A project with a package.json at its root (or in a known folder).
- A build script if your framework needs one (Next.js, Vite, React, Angular, Nuxt).
- A start command or entry file for server apps (Express, Fastify, NestJS) – for example server.js.
- Your environment variables, such as database URLs and API keys.
- A domain pointed to your hosting, ideally with SSL (why HTTPS matters).
Step 1: Prepare package.json
Make sure package.json lists all dependencies (not just in your local node_modules), and has scripts like:
"scripts": {
"build": "next build",
"start": "next start"
}
Specify the Node.js version your app needs, and commit your lock file (package-lock.json, yarn.lock or pnpm-lock.yaml).
Step 2: Choose how to deploy
- Upload a zip: compress the project folder without node_modules and build output. Dependencies are installed on the server.
- Connect GitHub or GitLab: the host downloads your branch and builds it. This is easier for updates.
Step 3: Review the build settings
A good hosting panel reads package.json and suggests settings. Check:
| Setting | Example |
|---|
| Framework | Next.js, Express, Vite |
| Node.js version | 20 or 22 |
| Build script | build |
| Output folder | .next, dist or build |
| Entry file (server apps) | server.js |
| Package manager | npm, yarn or pnpm |
Step 4: Set environment variables
Never put secrets in your code. Add variables like DATABASE_URL, API keys and JWT secrets in the hosting panel. Remember: some frameworks (like Next.js with NEXT_PUBLIC_ variables) read values at build time, so you must redeploy after changing them.
Step 5: Deploy and watch the build log
Start the deploy and follow the log. A typical log shows dependency installation, the build and the app starting. When it completes, open your domain and test the main pages and API routes.
Fixing a failed Node.js app build
- Module not found: a dependency is missing from package.json – add it and redeploy.
- Wrong Node.js version: choose the version your framework requires.
- Build script missing: check the script name in package.json.
- App starts but crashes: check runtime logs for missing environment variables or database connection errors.
- Port errors: read the port from process.env.PORT instead of hard-coding it.
Step 6: Automate deploys from GitHub
Add the webhook address from your hosting panel to your repository settings. Every push to your main branch then rebuilds and deploys automatically – no manual uploads.
Keep your Node.js app healthy
- Watch runtime logs for errors after each deploy.
- Restart the app after changing environment variables (when not rebuilding).
- Update dependencies regularly and check for security advisories.
- Keep secrets out of the repository.
Frequently asked questions
Can I host a Node.js app on shared hosting?
Some hosting plans now support Node.js apps with automatic builds, so you do not need a separate server. Check that your plan supports Node.js and the version your framework needs.
Should I upload node_modules with my app?
No. Leave node_modules out of the zip. The server installs dependencies from your package.json and lock file, which keeps uploads small and avoids compatibility problems.
Why does my Node.js app work locally but not after deploy?
Common reasons are missing environment variables, a dependency installed globally on your computer but not listed in package.json, a different Node.js version, or a hard-coded port instead of process.env.PORT.
Summary
To deploy a Node.js app, prepare a clean package.json, upload a zip or connect GitHub, review the detected build settings, add environment variables, follow the build log and automate future deploys with a webhook.
Our web hosting includes Node.js app deploys from a zip or GitHub/GitLab with live build logs, environment variables and push-to-deploy. Need a custom app built? See software development or contact us.