Answers for "how to change port for nodejs"

2

change port in npm start

npm run dev -- --port 8080
Posted by: Guest on March-23-2021
1

SERVER PORT NODE.JS

const http = require('http');

const hostname = '127.0.0.1';
const port = 3000;

const server = http.createServer((req, res) => {
  res.statusCode = 200;
  res.setHeader('Content-Type', 'text/plain');
  res.end('Hello World');
});

server.listen(port, hostname, () => {
  console.log(`Server running at http://${hostname}:${port}/`);
});
Posted by: Guest on April-28-2020

Code answers related to "how to change port for nodejs"

Browse Popular Code Answers by Language