DEVLOG

Next.js ์‹œ์ž‘ํ•˜๊ธฐ ๋ณธ๋ฌธ

frontend/next.js

Next.js ์‹œ์ž‘ํ•˜๊ธฐ

meroriiDev 2023. 6. 19. 22:25
728x90
๋ฐ˜์‘ํ˜•
 
๐Ÿ“–  ๋ชฉ์ฐจ

     

    create-next-app ์„ค์น˜

    ๋จผ์ € Next.js๋ฅผ ์‚ฌ์šฉํ•œ ํ”„๋กœ์ ํŠธ๋ฅผ ์ƒ์„ฑํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” create-next-app์„ ๋จผ์ € ์„ค์น˜ํ•ด์•ผํ•œ๋‹ค.

    ๋ฌธ๋“ ๋“œ๋Š” ์ƒ๊ฐ์ธ๋ฐ,,, create-react-app์„ CRA๋ผ๊ณ  ๋ถ€๋ฅด๋Š” ๊ฒƒ ์ฒ˜๋Ÿผ create-next-app๋„ CNA๋ผ๊ณ  ๋ถ€๋ฅผ๊นŒ,,?๐Ÿค” (์˜ค ๊ทธ๋ ‡๋‹ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค...!!!)

    npm install -g create-next-app


    ์„ค์น˜ ์™„๋ฃŒ ํ›„ ์ •์ƒ์ ์œผ๋กœ ์„ค์น˜๊ฐ€ ๋˜์—ˆ๋Š”์ง€ ๋‹ค์Œ ๋ช…๋ น์–ด๋ฅผ ํ†ตํ•ด ํ™•์ธํ•œ๋‹ค.

    $ create-next-app --version
    12.1.6

     

    create-next-app ์ƒ์„ฑ

    ์ด์ œ ์œ„์—์„œ ์„ค์น˜ํ•œ create-next-app์„ ์‚ฌ์šฉํ•˜์—ฌ ์•„๋ž˜ ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ•˜์—ฌ Next.js ํ”„๋กœ์ ํŠธ๋ฅผ ์ƒ์„ฑํ•ด๋ณด์ž!

    npx create-next-app --typescript mypage(project๋ช…)

     

    Next.jsํŽ˜์ด์ง€ ์‹คํ–‰

    ํ”„๋กœ์ ํŠธ๊ฐ€ ์ƒ์„ฑ์ด ์™„๋ฃŒ๋˜๋ฉด ํ”„๋กœ์ ํŠธ ์‹คํ–‰์— ๊ด€ํ•œ ์นœ์ ˆํ•œ ๋ฉ”์„ธ์ง€๊ฐ€ ์ถœ๋ ฅ๋œ๋‹ค.

    Success! Created portfolio at ...
    Inside that directory, you can run several commands:
    
      yarn dev
        Starts the development server.
    
      yarn build
        Builds the app for production.
    
      yarn start
        Runs the built app in production mode.
    
    We suggest that you begin by typing:
    
      cd portfolio
      yarn dev
    

     

    ํด๋”๋กœ ๋“ค์–ด๊ฐ€์„œ yarn devํ•˜์„ธ์š”! (so์นœ์ ˆ,,)

    ์ด๋ ‡๊ฒŒ ์นœ์ ˆํ•˜๊ฒŒ ์•Œ๋ ค์ค˜๋„ ๊ตณ์ด ๋“ค์–ด๊ฐ€์„œ yarn startํ•˜๋Š” ์‚ฌ๋žŒ์ด ์žˆ๋‹ค?

    (๋‚˜)

    ........๐Ÿคญ

     

    ์ƒ์„ฑ๋œ ํ”„๋กœ์ ํŠธ์˜ package.json์„ ํ™•์ธํ•ด๋ณด๋ฉด ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ ์Šคํฌ๋ฆฝํŠธ๊ฐ€ ๊ธฐ๋ณธ์œผ๋กœ ๋“ค์–ด๊ฐ€์žˆ๋‹ค.

      "scripts": {
        "dev": "next dev",
        "build": "next build",
        "start": "next start",
        "lint": "next lint"
      },
    • dev: Next.js ํ”„๋กœ์ ํŠธ๋ฅผ ๊ฐœ๋ฐœ ๋ชจ๋“œ(development mode)๋กœ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.
    • build: Next.js ํ”„๋กœ์ ํŠธ๋ฅผ production mode๋กœ ๋นŒ๋“œํ•ฉ๋‹ˆ๋‹ค.
    • start: Next.js ํ”„๋กœ์ ํŠธ๋ฅผ productoin mode๋กœ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.
    • lint: Next.js์— ๊ธฐ๋ณธ ์„ค์ •๋œ ESLint ์„ค์ •์„ ์‚ฌ์šฉํ•˜์—ฌ ESLint๋ฅผ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.

     

    ์ƒˆ๋กญ๊ฒŒ ์ƒ์„ฑํ•œ Next.js ํ”„๋กœ์ ํŠธ๋ฅผ ์‹คํ–‰ํ•˜๊ธฐ ์œ„ํ•ด์„œ ๋‹ค์Œ์˜ ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ•œ๋‹ค.

    yarn dev
    ๋˜๋Š”
    npm run dev

     

    ์œ„ ๋ช…๋ น์–ด๊ฐ€ ์ •์ƒ์ ์œผ๋กœ ์‹คํ–‰๋˜๋ฉด http://localhost:3000 ์—์„œ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ํ™”๋ฉด์ด ํ‘œ์‹œ๋˜๋ฉฐ ์•ž์œผ๋กœ ๊ฐ€๊ฟ”๋‚˜๊ฐˆ ํ”„๋กœ์ ํŠธ๊ฐ€ ์ค€๋น„๋˜์—ˆ์Šต๋‹ˆ๋‹ค! ์•„์Ÿˆ์Ÿˆ๐Ÿ˜†๐Ÿ”ฅ

     

    728x90
    ๋ฐ˜์‘ํ˜•
    Comments