๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๐Ÿ“‚ Library/React

React ์ดˆ๋ณด๋ฅผ ์œ„ํ•œ ๋ฆฌ์•กํŠธ ์‹œ์ž‘ํ•˜๊ธฐ

by Dev. Ella 2023. 4. 27.
โœ… ์ด ๊ธ€์€ mac OS & VScode ์‚ฌ์šฉ์ž์—๊ฒŒ ๋งž์ถฐ์ ธ ์žˆ๋Š” ์  ์ฐธ๊ณ  ๋ฐ”๋ž๋‹ˆ๋‹ค.

 

1.  iterm or Terminal์—์„œ ๋””๋ ‰ํ† ๋ฆฌ ๋งŒ๋“ค๊ธฐ

# mkdir ๋ช…๋ น์–ด๋กœ ํ”„๋กœ์ ํŠธ๋ฅผ ์‹œ์ž‘ํ•˜๋ ค๋Š” ํด๋”์—์„œ ๋””๋ ‰ํ† ๋ฆฌ๋ฅผ ๋งŒ๋“ ๋‹ค.
yeonsuchoi@Ella-iMac Workspace % mkdir React

# cd ๋ช…๋ น์–ด๋กœ ๋งŒ๋“ค์—ˆ๋˜ ๋””๋ ‰ํ† ๋ฆฌ ์•ˆ์— ๋“ค์–ด๊ฐ„๋‹ค. (์ƒ๋žต ๊ฐ€๋Šฅ)
yeonsuchoi@Ella-iMac Workspace % cd React

 

2. ๋ฆฌ์•กํŠธ ์„ค์น˜ํ•˜๊ธฐ

# ๋””๋ ‰ํ† ๋ฆฌ ์•ˆ์—์„œ npx create-react-app {๋””๋ ‰ํ† ๋ฆฌ๋ช…} ์„ ์ž…๋ ฅํ•œ๋‹ค.
# ๋‹จ, ์•„๋ž˜์™€ ๊ฐ™์ด ๋””๋ ‰ํ† ๋ฆฌ ๋ช…์„ ๋Œ€๋ฌธ์ž๋กœ ์ž…๋ ฅํ•˜๋ฉด ์•„๋ž˜์™€ ๊ฐ™์€ ์—๋Ÿฌ ์ฝ”๋“œ๊ฐ€ ๋œฌ๋‹ค.
yeonsuchoi@Ella-iMac React % npx create-react-app CodingApple

name can no longer contain capital letters
Please choose a different project name.

# ๋”ฐ๋ผ์„œ ์•„๋ž˜์™€ ๊ฐ™์ด ์†Œ๋ฌธ์ž๋กœ ์ž‘์„ฑํ•œ๋‹ค.
yeonsuchoi@Ella-iMac React % npx create-react-app codingapple

# ์ž˜ ์ž…๋ ฅํ–ˆ๋‹ค๋ฉด, prgress bar๊ฐ€ ๋‚˜ํƒ€๋‚˜๋ฉฐ ๋ฌด์–ธ๊ฐ€ ๋กœ๋”ฉ๋˜๊ณ , ์•„๋ž˜์™€ ๊ฐ™์€ ๋ฌธ์žฅ์ด ๋‚˜์˜ค๋ฉด ์„ฑ๊ณต!
Happy hacking!

# code .  ๋ช…๋ น์–ด๋กœ VScode๋ฅผ ์‹คํ–‰ํ•œ๋‹ค.
yeonsuchoi@Ella-iMac React % code .

 

3. ํ„ฐ๋ฏธ๋„์—์„œ ์‹คํ–‰ํ•˜๊ธฐ

VScode ์ƒ๋‹จ์˜ Terminal > New Terminal ํด๋ฆญ ํ˜น์€ ๋‹จ์ถ•ํ‚ค์ธ control + Shift + ๋ฐฑํ‹ฑ ํ‚ค๋ฅผ ๋ˆŒ๋Ÿฌ ํ„ฐ๋ฏธ๋„์„ ์‹คํ–‰ํ•œ๋‹ค.

 

4. ๋ฆฌ์•กํŠธ๋ฅผ ๋ธŒ๋ผ์šฐ์ €์—์„œ ์‹คํ–‰ํ•˜๊ธฐ

# ์•„๋ž˜์˜ ๋ช…๋ น์–ด๋ฅผ ํ„ฐ๋ฏธ๋„์— ์ž…๋ ฅํ•œ๋‹ค.
npm start

# ๋‹จ, ์—ฌ๊ธฐ์„œ ๋ฐ˜๋“œ์‹œ ํ•ด๋‹น ๋””๋ ‰ํ† ๋ฆฌ ์•ˆ์— ๋“ค์–ด๊ฐ€์„œ ์‹คํ–‰ํ•ด์•ผ ํ•œ๋‹ค.
# ์˜ˆ๋ฅผ ๋“ค์–ด, ๋‚ด๊ฐ€ ๋ฆฌ์•กํŠธ ์„ค์น˜ํ•œ ๋””๋ ‰ํ† ๋ฆฌ ๋ช…์ด codingapple์ธ๋ฐ React์—์„œ ์‹คํ–‰ํ•˜๋ฉด ์•ˆ๋œ๋‹ค.
yeonsuchoi@Ella-iMac React % (X)
yeonsuchoi@Ella-iMac codingapple % npm start (O)

npm start๋ฅผ ์ž…๋ ฅํ•˜๋ฉด ์•„๋ž˜์™€ ๊ฐ™์ด ๋ธŒ๋ผ์šฐ์ €์—์„œ ๋ฆฌ์•กํŠธ๊ฐ€ ์‹คํ–‰๋œ๋‹ค.

 

5. ํ”„๋กœ์ ํŠธ ํŒŒ์ผ๋“ค ์‚ดํŽด๋ณด๊ธฐ

- node_modules: ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์ฝ”๋“œ ๋ณด๊ด€ํ•จ

- public ํด๋”: static ํŒŒ์ผ๋“ค ๋ชจ์•„๋‘๋Š” ๊ณณ (html, img ๋“ฑ)

- src ํด๋”: ์ฝ”๋“œ ์งœ๋Š” ๊ณณ

- App.js: ์ด ์•ˆ์—์„œ JavaScript ์ฝ”๋“œ๋ฅผ ์งœ๋ฉด ๋˜๋ฉฐ, ๋ฉ”์ธ์ด๋ผ๊ณ  ๋ณด๋ฉด ๋จ

- package.json: ํ”„๋กœ์ ํŠธ ์ •๋ณด

 

 

 

๐Ÿ“Ž ๋‚ด์šฉ ์ฐธ์กฐ

Youtube ์ฝ”๋”ฉ์• ํ”Œ - 2022 new ๋ฆฌ์•กํŠธ 1๊ฐ• : ๋ฆฌ์•กํŠธ ๋ฝ•์ฃผ์ž…๊ณผ ์„ค์น˜๋ฒ•

๋Œ“๊ธ€