Creating new server in node.js
Muhammadaziz
Posted on December 26, 2021
Firstly install express
const express = require("express")
const app = express()
Then add to server.js or other js files to listen port
app.listen(4000, ()=>{
console.log("server is running on port: 4000")
})
Or if you want to this way. This way is also good. It's best practices
const PORT = process.env.PORT || 4000
app.listen(PORT, ()=>{
console.log(PORT)
})
💖 💪 🙅 🚩
Muhammadaziz
Posted on December 26, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
nextjs Efficiently Manage Errors in Next.js with a Comprehensive Developer Solution
October 31, 2024