๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
  • What would life be If we had no courage to attemp anything?
Development/React.js

[React] port ๋ฒˆํ˜ธ ๋ณ€๊ฒฝํ•˜๊ธฐ

by DevIseo 2023. 1. 23.

๋ฐฉ๋ฒ•1. ๋ช…๋ น์–ด๋กœ ์‹คํ–‰ (1ํšŒ์„ฑ)

PORT=[์ˆซ์ž] npm run start

๋ฐฉ๋ฒ•2. package.json ์ˆ˜์ •

window

...
"scripts": {
   "start": "set PORT=3002 && react-scripts start",
}
...

๋ฐฉ๋ฒ•3. ํ”„๋กœ์ ํŠธ๋ช…/node_modules/react-scripts/scripts/start.js ์ˆ˜์ •ํ•˜๊ธฐ

const DEFAULT_PORT = parseInt(process.env.PORT, 10) || 3002;	// ์ˆ˜์ •
const HOST = process.env.HOST || '0.0.0.0';

๋ฐฉ๋ฒ•4. .env ํŒŒ์ผ ์ƒ์„ฑํ•˜๊ณ  port ์„ค์ •ํ•˜๊ธฐ

ํ”„๋กœ์ ํŠธ๋ช…/.env

PORT=3002

๋ช…๋ น์–ด๋กœ ์‹คํ–‰

npm run start

Reference

[#. React] React ๊ธฐ๋ณธ ์‹คํ–‰ 3000 port ๋ณ€๊ฒฝํ•˜๊ธฐ

'Development > React.js' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

[React] console.log(useRef)  (0) 2023.01.25
[React] ref, useRef  (0) 2023.01.24
[React] React Hook API  (0) 2023.01.18
[React] React Life Cycle ; ๋ฆฌ์•กํŠธ ์ƒ๋ช…์ฃผ๊ธฐ  (0) 2023.01.14
SPA / CSR / TTI / TTV / SEO / Metaํƒœ๊ทธ / Opengraph  (0) 2022.10.14

๋Œ“๊ธ€