Deploying Node.js
Native support for Node.js applications with automatic dependency detection, optimized build caching, and zero-downtime deployments.
Supported Runtimes
Abasthan supports all active LTS versions of Node.js. You can specify your desired version during the deployment setup or let Abasthan detect it from your package.json engine field.
- Node.js 22 (Current Default)
- Node.js 20
- Node.js 18
Quick Start Guide
To deploy a Node.js app, ensure your repository has a package.json file. Abasthan will automatically detect your project and suggest the following build steps:
Build Command
The build command must prepare your application for production. It must include dependency installation because Abasthan starts each build in a clean environment.
npm install && npm run buildStart Command
This command is used to launch your application. It should start a web server listening on all interfaces.
npm startPort Configuration
Abasthan automatically detects the port your application is listening on. However, for the best reliability, we recommend listening on the port provided by the PORT environment variable and binding to 0.0.0.0.
const port = process.env.PORT || 3000;
app.listen(port, '0.0.0.0', () => {
console.log(`Server running on port ${port}`);
});Best Practices
- Graceful Shutdown: Listen for
SIGTERMsignals to close database connections and finish processing requests before the container stops. - Build Caching: Keep your
node_modulesin the root directory to leverage Abasthan's lightning-fast dependency caching. - Logging: Stream logs to
stdoutandstderr. Abasthan automatically captures these and displays them in your real-time dashboard.
Troubleshooting
Common issues include missing dependencies or incorrect start commands. Always verify your build logs in the dashboard for detailed error messages.