Deploy Node.js (Express) Projects in Seconds
How to deploy Node.js? Deploying the Node.js and Express.js ecosystem, which is the backbone of modern web APIs, can sometimes require complex server configurations. But with Flyway, Express.js hosting and deployment processes are completely automated.
Unlike platforms such as Heroku, Railway, or Vercel, Flyway analyzes your project via GitHub, compiles it in seconds with a zero-config principle, and takes it live with SSL in a completely isolated environment that belongs to you. Moreover, you don't need to write complex Procfile or Dockerfile.
Table of Contents (What will you learn?)
1. Prerequisites
Before taking your project live on Flyway, make sure you meet the following requirements:
- ✅ Your project must be hosted on a GitHub, GitLab, or Bitbucket repository.
- ✅ A valid
package.jsonfile must be present in the root directory of your project. - ✅ You must have logged into your Flyway account and completed the GitHub integration.
2. Specifying Node.js Version (Engines)
One of the most common errors encountered in production is the mismatch between the local Node.js version and the server version. Flyway uses the current LTS version (e.g., Node 20.x) by default. However, if your project requires a specific Node version, you can specify this in the engines field in your package.json file.
"name": "my-api",
"engines": {
"node": "18.x" // Flyway will use the image suitable for this version
}
}
3. Start Script and TypeScript Build Steps
Flyway triggers the start and build scripts in your package.json file directly to boot up your Node.js project. Tools like nodemon or ts-node-dev that you use in your development environment should not be used in production.
For Standard JavaScript Projects
"start": "node index.js", // Flyway starts the project with this command
"dev": "nodemon index.js"
}
For TypeScript Projects (Important)
Today, most new Express projects are written with TypeScript. Since your TypeScript code cannot run directly on the server (it causes performance loss), it needs to be compiled (build) first. If Flyway sees a build script in your repository, it will automatically run it.
"build": "tsc", // 1. Flyway does the compilation (build) first
"start": "node dist/index.js", // 2. Flyway runs the compiled JS file
"dev": "ts-node-dev src/index.ts"
}
4. Port Listening Rules (Crucial)
The biggest reason Node.js projects crash on PaaS systems is incorrect port listening configurations. Flyway (and modern cloud platforms) assigns your app a random dynamic port and routes traffic to it.
You must not bind your app to a static port (e.g., 3000) or just localhost (127.0.0.1). This will disconnect your app from the outside world.
Your app must read the process.env.PORT variable and listen to the 0.0.0.0 host address.
const host = '0.0.0.0';
app.listen(port, host, () => {
console.log(`Server running on ${host}:${port}`);
});
5. Environment Variables (.env) Management
You should never write sensitive data such as database passwords, API keys, or JWT secret keys used by your application directly into your code (hardcoded) or in your .env file on GitHub. You can safely add all this data from the "Environment Variables" tab in the Flyway panel.
6. Log Viewing and Debugging (Crash Loop)
Sometimes your project might successfully deploy but constantly restart (Crash Loop). The only way to understand what the error is when your Node.js application crashes is to read the logs.
- Go to your Flyway project control panel.
- Click on the Logs tab from the top menu.
- Monitor your application's
console.log()and error outputs in Real-time. You can instantly spot database connection errors or missing module errors here.
7. Troubleshooting & FAQ
Frequently Asked Questions
How to deploy Node.js?
Just create a "New Project" on Flyway and select your GitHub repository. Flyway detects that your project is Node.js, installs dependencies, and takes it live including SSL.
Troubleshooting Table (Errors and Solutions)
| Error Message / Symptom | Possible Cause | Solution |
|---|---|---|
| Web process failed to bind to $PORT | Your app is listening on a static port (e.g. 3000). | Update your code to app.listen(process.env.PORT || 3000, '0.0.0.0'). |
| Missing start script | There is no "start" command in package.json. |
Add "start": "node index.js" to the "scripts" block. |
| Cannot find module 'express' | The package was installed in devDependencies. |
Move the module to the dependencies block and commit again. |
Web process failed to bind to $PORT
app.listen(process.env.PORT || 3000, '0.0.0.0').
Missing start script
package.json.
"start": "node index.js" to the "scripts" block.
Cannot find module 'express'
devDependencies.
dependencies block and commit again.
Related Articles
Node.js Environment Variables (.env) →
Learn how to securely manage your API keys and database passwords.
Deploy NestJS Projects →
Take your projects written with the modern TypeScript framework NestJS live.
You're All Set! 🚀
After these configurations, just push your project. Flyway compiles your app in seconds and takes it live on your Custom Domain.