how to set port number in react js code example

Example 1: set port in react app

//in package.json

"start": "react-scripts start"
t0
//linux
"start": "PORT=3006 react-scripts start"
or 
"start": "export PORT=3006 react-scripts start"
//windows
"start": "set PORT=3006 && react-scripts start"

Example 2: react port

// Ubuntu / CentOS / RHEL / MacOS environment:

...
  "scripts": {
    "start": "PORT=8000 react-app-rewired start",
    "build": "react-app-rewired build",
    "test": "react-app-rewired test --env=jsdom",
    "eject": "react-app-rewired eject"
  }
...

Tags:

Misc Example