How npm start runs a server on port 8000
Solution 1:
We have a react application and our development machines are both mac and pc. The start command doesn't work for PC so here is how we got around it:
"start": "PORT=3001 react-scripts start",
"start-pc": "set PORT=3001&& react-scripts start",
On my mac:
npm start
On my pc:
npm run start-pc
Solution 2:
If you will look at package.json
file.
you will see something like this
"start": "http-server -a localhost -p 8000"
This tells start a http-server
at address of localhost
on port 8000
http-server is a node-module.
Update:- Including comment by @Usman, ideally it should be present in your package.json
but if it's not present you can include it in scripts
section.
Solution 3:
To change the port
npm start --port 8000
Solution 4:
To start the port correctly in your desired port use:
npm start -- --port 8000