๐Ÿ“ข๐Ÿšจ๐Ÿšจnpx create-next-app@latest๊ฐ€ ์ž‘๋™ํ•˜์ง€ ์•Š์Œ - ์ด ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜๋Š” ๋ฐฉ๋ฒ•

๐Ÿ”ด: ์ €๋„ ๊ฐ™์€ ๋ฌธ์ œ๋ฅผ ๊ฒช๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ์นœ๊ตฌ ์—ฌ๋Ÿฌ๋ถ„์„ ์œ„ํ•ด ๊ฒŒ์‹œ๋ฌผ์„ ์ž‘์„ฑํ•ด์•ผ ํ•  ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค. ์ด ๋ฌธ์ œ๋ฅผ ์–ด๋–ป๊ฒŒ ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๊นŒ? ์‚ฌ์ดํŠธ, ํฌ๋Ÿผ, GitHubissues๋ฅผ ๋งŽ์ด ๊ฒ€์ƒ‰ํ•˜์ง€๋งŒ ์ฐพ์„ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค. ์ด ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•œ ๋ฌธ์ œ์— ๋Œ€ํ•œ ํŠธ๋ฆญ์„ ์‚ฌ์šฉํ–ˆ์Šต๋‹ˆ๋‹ค. ๋ชจ๋“  JavaScript ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ, ํ”„๋ ˆ์ž„์›Œํฌ ๋ฐ ๋‹ค๋ฅธ ํ”„๋กœ์ ํŠธ์—์„œ๋„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์•ˆ๋…•ํ•˜์„ธ์š”, JSSTACKDEVELOPERS์˜ M Ahmed์ž…๋‹ˆ๋‹ค. ์นœ๊ตฌ๋“ค๊ณผ ์ด์•ผ๊ธฐํ•˜๊ฒŒ ๋˜์–ด ๋งค์šฐ ๊ธฐ์ฉ๋‹ˆ๋‹ค.



์š”์ ์œผ๋กœ ๊ฐ‘์‹œ๋‹ค.

๋‹ค์Œ๊ณผ ๊ฐ™์€ ํ”„๋กœ์ ํŠธ์—์„œ ์ด ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ–ˆ์Šต๋‹ˆ๋‹ค.


์ด์ œ ํ•ด๋‹น ๋ฌธ์ œ์˜ ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•์œผ๋กœ ์ด๋™ํ•ด ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.

๋จผ์ € ์‹œ์Šคํ…œ์— ์ „์—ญ์œผ๋กœ create-next-app๋ฅผ ์„ค์น˜ํ•ฉ๋‹ˆ๋‹ค.



By using npm package manger:
--------------------
npm install --global create-next-app@latest
or
npm i -g create-next-app@latest

If you are yarn package manger user then apply these commands:
By using yarn package manger:
--------------------
yarn add --global create next-app
or
yarn add -g create next-app


TypeScript๋Š” ์‹œ์Šคํ…œ์— ์ „์ฒด์ ์œผ๋กœ ์„ค์น˜๋ฉ๋‹ˆ๋‹ค.
๐Ÿ‘‰๐Ÿ‘‰ ์‹œ์Šคํ…œ์—์„œ ๋‹ค์Œ ๋””๋ ‰ํ† ๋ฆฌ๋กœ ์ด๋™ํ•ฉ๋‹ˆ๋‹ค.C:\Users\<username>\AppData\Roaming\npm๋‹ค์Œ๊ณผ ๊ฐ™์€ ๊ฒƒ์„ ์ฐพ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.


์ด์ œ node_modules ํด๋”๋ฅผ ์—ด๋ฉด create-next-app ํด๋”๋ฅผ ์ฐพ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.

์ด์ œ dist ํด๋”๋กœ ์ด๋™ํ•˜์—ฌ Templates ๋ฐ typescript ๋‘ ๊ฐœ์˜ ํด๋”๋ฅผ ๋” ์ฐพ์„ ์ˆ˜ ์žˆ๋Š” default ํด๋”๋ฅผ ์ฐพ์Šต๋‹ˆ๋‹ค. ์ด๊ฒƒ๋“ค์€ ์šฐ๋ฆฌ ํ”„๋กœ์ ํŠธ์— ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.

์ด์ œ ํ”„๋กœ์ ํŠธ๋ฅผ ์œ„ํ•ด Bash or Terminal๋ฅผ ์„ค์น˜ํ•˜๋ ค๋Š” Next.JS - App๋ฅผ ์—ฝ๋‹ˆ๋‹ค.

create-next-app my-app


๊ฐ€์ง€๊ณ  ์žˆ๋Š” ๊ฒฝ์šฐ ๊ธฐ๋ณธ์ ์œผ๋กœ yarn-package manger๋กœ ์„ค์น˜๋ฉ๋‹ˆ๋‹ค. ๊ทธ๋ ‡์ง€ ์•Š์œผ๋ฉด npm-package manger๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.

์„ค์น˜๊ฐ€ ์™„๋ฃŒ๋œ ํ›„:
npm run dev or yarn dev๋ฅผ ์‹คํ–‰ํ•˜์—ฌ http://localhost:3000์—์„œ ๊ฐœ๋ฐœ ์„œ๋ฒ„๋ฅผ ์‹œ์ž‘ํ•ฉ๋‹ˆ๋‹ค.
์‹ ์ฒญ์„œ๋ฅผ ๋ณด๋ ค๋ฉด http://localhost:3000 ์„ ๋ฐฉ๋ฌธํ•˜์‹ญ์‹œ์˜ค.

ํŽธ์ง‘pages/index.jsํ•˜๊ณ  ๋ธŒ๋ผ์šฐ์ €์—์„œ ์—…๋ฐ์ดํŠธ๋œ ๊ฒฐ๊ณผ๋ฅผ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค.create-next-app ์‚ฌ์šฉ ๋ฐฉ๋ฒ•์— ๋Œ€ํ•œ ์ž์„ธํ•œ ๋‚ด์šฉ์€ [ create-next-app documentation ]( https://nextjs.org/docs )์„ ์ฐธ์กฐํ•˜์‹ญ์‹œ์˜ค.

๋˜๋Š”


์ˆ˜๋™ ์„ค์ •



ํ”„๋กœ์ ํŠธ์— next , react ๋ฐ react-dom๋ฅผ ์„ค์น˜ํ•ฉ๋‹ˆ๋‹ค.

npm install next react react-dom
# or
yarn add next react react-dom

package.json๋ฅผ ์—ด๊ณ  ๋‹ค์Œscripts์„ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.

"scripts": {
  "dev": "next dev",
  "build": "next build",
  "start": "next start",
  "lint": "next lint"
}


์ด๋Ÿฌํ•œ ์Šคํฌ๋ฆฝํŠธ๋Š” ์‘์šฉ ํ”„๋กœ๊ทธ๋žจ ๊ฐœ๋ฐœ์˜ ์—ฌ๋Ÿฌ ๋‹จ๊ณ„๋ฅผ ๋‚˜ํƒ€๋ƒ…๋‹ˆ๋‹ค.
dev - ๊ฐœ๋ฐœ ๋ชจ๋“œ์—์„œ Next.js๋ฅผ ์‹œ์ž‘ํ•˜๋Š” ์‹คํ–‰next devbuild - ํ”„๋กœ๋•์…˜ ์šฉ๋„๋กœ ์‘์šฉ ํ”„๋กœ๊ทธ๋žจ์„ ๋นŒ๋“œํ•˜๋Š” ์‹คํ–‰next buildstart - Next.js ํ”„๋กœ๋•์…˜ ์„œ๋ฒ„๋ฅผ ์‹œ์ž‘ํ•˜๋Š” ์‹คํ–‰next startlint - Next.js์˜ ๋‚ด์žฅ ESLint ๊ตฌ์„ฑ์„ ์„ค์ •ํ•˜๋Š” ์‹คํ–‰next lintNext.js๋Š” ํŽ˜์ด์ง€ ๊ฐœ๋…์„ ๊ธฐ๋ฐ˜์œผ๋กœ ๊ตฌ์ถ•๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ํŽ˜์ด์ง€๋Š” ํŽ˜์ด์ง€ ๋””๋ ‰ํ† ๋ฆฌ์˜ .js , .jsx , .ts ๋˜๋Š” .tsx ํŒŒ์ผ์—์„œ ๋‚ด๋ณด๋‚ธ React ๊ตฌ์„ฑ ์š”์†Œ์ž…๋‹ˆ๋‹ค.

ํŽ˜์ด์ง€๋Š” ํŒŒ์ผ ์ด๋ฆ„์„ ๊ธฐ๋ฐ˜์œผ๋กœ ๊ฒฝ๋กœ์™€ ์—ฐ๊ฒฐ๋ฉ๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด pages/about.js๋Š” /about์— ๋งคํ•‘๋ฉ๋‹ˆ๋‹ค. ํŒŒ์ผ ์ด๋ฆ„์œผ๋กœ ๋™์  ๊ฒฝ๋กœ ๋งค๊ฐœ๋ณ€์ˆ˜๋ฅผ ์ถ”๊ฐ€ํ•  ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค.

ํ”„๋กœ์ ํŠธ ๋‚ด์— ํŽ˜์ด์ง€ ๋””๋ ‰ํ† ๋ฆฌ๋ฅผ ๋งŒ๋“ญ๋‹ˆ๋‹ค.

๋‹ค์Œ ์ฝ˜ํ…์ธ ๋กœ ์ฑ„์šฐ๊ธฐ./pages/index.js:

function HomePage() {
  return <div>Welcome to Next.js!</div>
}

export default HomePage


์ง€๊ธˆ๊นŒ์ง€ ์šฐ๋ฆฌ๋Š” ๋‹ค์Œ์„ ์–ป์Šต๋‹ˆ๋‹ค.
์ž๋™ ์ปดํŒŒ์ผ ๋ฐ ๋ฒˆ๋“ค๋ง
๋น ๋ฅธ ์ƒˆ๋กœ๊ณ ์นจ ๋ฐ˜์‘./pages/์˜ ์ •์  ์ƒ์„ฑ ๋ฐ ์„œ๋ฒ„์ธก ๋ Œ๋”๋ง
์ •์  ํŒŒ์ผ ์ œ๊ณต. ./public/๋Š” /์— ๋งคํ•‘๋ฉ๋‹ˆ๋‹ค.

๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค~ M Ahmed -- ์งˆ๋ฌธ์ด ๋” ์žˆ์œผ๋ฉด ์ž์œ ๋กญ๊ฒŒ ๋ฌผ์–ด๋ณด์„ธ์š”.
#jsstack๊ฐœ๋ฐœ์ž ๐Ÿš€๐Ÿš€

์ข‹์€ ์›นํŽ˜์ด์ง€ ์ฆ๊ฒจ์ฐพ๊ธฐ