This content originally appeared on DEV Community and was authored by Muhammadaziz
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)
})
This content originally appeared on DEV Community and was authored by Muhammadaziz

Muhammadaziz | Sciencx (2021-12-26T16:44:11+00:00) Creating new server in node.js. Retrieved from https://www.scien.cx/2021/12/26/creating-new-server-in-node-js/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.