Consider this code:
const http = require("http") const port = 8080 let myServer = http.createServer() myServer.listen(port) function serverSetOnF