Change PORT for ReactJS App | Specify Custom PORT for React Project

preview_player
Показать описание
How to change port in react js? ReactJS app created with create-react-app has got default PORT that is 3000. App runs at 3000 port. What if some other program is already using same PORT? Or you may want to change port for project's specific need. How can we change port for ReactJS app?

It is very easy. We can change reactJS app port in multiple ways. One way is to use .env file
.env is an environment variable file and is hidden. It is treated as system file. Create .env file if it's not already there at project root level and specify port number there.

Original Start Command
"start": "react-scripts start"
Change it to
"start": "set PORT=3001 && react-scripts start"

In my opinion, using .env file to change port is cleaner way to change project port.

Thank You!
👍 LIKE VIDEO
👊 SUBSCRIBE
🔔 PRESS BELL ICON
✍️ COMMENT

#react #reactjs #js #javascript #port #webdevelopment #nodejs #webstylepress #env
Рекомендации по теме
Комментарии
Автор

Sənin qadan alaram BRO. Köməyin üçün çox sağol )

kingarmande
Автор

OK thanks, but you did not mention where we will find the DOT ENV file first ??

ahmedyassinehamdouni