Hey there, coding champ! ๐ So youโve built a cool Node.js app on your computer… Now youโre wondering: โHow do I show this to the world?โ ๐
Well, thatโs what deployment is all about.
Weโre going to learn how to deploy your Node.js app, step by step โ just like putting your project on stage for everyone to see ๐ค.
๐ What is Deployment?
Deployment means moving your code from your local machine to a public server so others can access it using a browser.
Itโs like turning your personal app into a live website.
๐งณ Different Deployment Options for Node.js Apps
There are many ways to deploy a Node.js app, like choosing the best travel option โ๏ธ๐๐.
๐ฅ Popular Cloud Platforms:
Platform
Features
Heroku
Easiest to use, great for beginners ๐ฏ
Render
Free tier, easy GitHub integration
Vercel
Best for front-end, but can host Node.js functions too โก
Railway
Dev-friendly, free tier, and serverless-ready ๐
AWS EC2
More control, but advanced users only ๐ง
DigitalOcean
Good performance, affordable droplets ๐ง
๐ก Tip: If you’re just starting, use Heroku or Render. Theyโre simple and beginner-friendly.
๐งช Step-by-Step: Deploy on Heroku (Easy Method)
Letโs deploy a sample Node.js app on Heroku.
1๏ธโฃ Create a Simple App (If You Donโt Have One)
bashCopyEditmkdir myapp
cd myapp
npm init -y
npm install express
app.js
jsCopyEditconst express = require('express');
const app = express();
const PORT = process.env.PORT || 3000;
app.get('/', (req, res) => {
res.send('Hello from Web Codder ๐');
});
app.listen(PORT, () => {
console.log(`Server running on port ${PORT}`);
});
2๏ธโฃ Add a Procfile
This tells Heroku how to run your app.
Create a file named Procfile with no extension:
makefileCopyEditweb: node app.js
3๏ธโฃ Push Code to Git
bashCopyEditgit init
git add .
git commit -m "My first deploy"
Vikas Sankhla is a seasoned Full Stack Developer with over 7 years of experience in web development. He is the founder of Web Codder, a platform dedicated to providing comprehensive web development tutorials and resources. Vikas specializes in the MERN stack (MongoDB, Express.js, React.js, Node.js) and has been instrumental in mentoring aspiring developers through his online courses and content. His commitment to simplifying complex web technologies has made him a respected figure in the developer community.