React

[React] Vite + Yarn Berry ํ”„๋กœ์ ํŠธ ์„ค์ •

hyonie 2025. 2. 23. 23:52

 

๐Ÿ“‚ ๋ชฉ์ฐจ

     


    yarn berry ํ™œ์„ฑํ™”

    1. ํ”„๋กœ์ ํŠธ ์ƒ์„ฑ

    yarn create vite my-app --template react-ts

     

    2. yarn berry ์ดˆ๊ธฐํ™”

    yarn set version berry

     

    3. pnp ๋ฐฉ์‹ ์‚ฌ์šฉํ•˜์—ฌ ์˜์กด์„ฑ ๊ด€๋ฆฌ

    • .yarnrc.yml ํŒŒ์ผ์—์„œ nodeLinker: pnp ๋‚ด์šฉ์„ ์ถ”๊ฐ€
    • ์ด ์„ค์ •์„ ํ†ตํ•ด node_modules ํด๋” ์—†์ด๋„ ํŒจํ‚ค์ง€๋ฅผ ๊ด€๋ฆฌํ• ์ˆ˜ ์žˆ๋‹ค.

     

    4. yarn install ํŒจํ‚ค์ง€ ์„ค์น˜

    yarn install # .yarn/cache ์„ค์ •

     

    5. ZipFS ํ”Œ๋Ÿฌ๊ทธ์ธ ์„ค์น˜

     

    ์ฃผ์˜ํ•ด์•ผ ํ•  ์ด์Šˆ & ํ•ด๊ฒฐ์ฑ…

    1. ํƒ€์ž…์Šคํฌ๋ฆฝํŠธ ๊ฒฝ๋กœ ์ธ์‹ ๋ฌธ์ œ

    yarn dlx @yarnpkg/sdks vscode #Vs Code SDK ์„ค์น˜

    ์ด ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ•˜๋ฉด .vscode/settings.json ํŒŒ์ผ์ด ์ƒ์„ฑ๋˜๊ณ , VS Code๊ฐ€ ์˜ฌ๋ฐ”๋ฅด๊ฒŒ TypeScript๋ฅผ ์ธ์‹ํ•˜๊ฒŒ ๋œ๋‹ค.

     

    โœ… VS Code ์„ค์ • ์ ์šฉ ๋ฐฉ๋ฒ•:

    1. command + p(Mac) ๋˜๋Š” ctrl + p(Windows)
    2. ">" ์ž…๋ ฅ ํ›„ Select TypeScript Version ์„ ํƒ
    3. Use Workspace Version ํด๋ฆญํ•˜๋ฉด ํƒ€์ž…์Šคํฌ๋ฆฝํŠธ๊ฐ€ ์ •์ƒ์ ์œผ๋กœ ์ž‘๋™ํ•œ๋‹ค.

    2. zero-install ์‚ฌ์šฉ ์‹œ .gitignore ์„ค์ •

    Yarn์˜ Zero-Install ๊ธฐ๋Šฅ์„ ์‚ฌ์šฉํ•˜๋ฉด .yarn/cache ๋“ฑ์˜ ํด๋”๊ฐ€ .gitignore์— ์˜ฌ๋ฐ”๋ฅด๊ฒŒ ์„ค์ •๋˜์–ด์•ผ ํ•œ๋‹ค. ์•„๋ž˜ ์„ค์ • ์ถ”๊ฐ€

    .yarn/*
    !.yarn/cache
    !.yarn/patches
    !.yarn/plugins
    !.yarn/releases
    !.yarn/sdks
    !.yarn/versions

    https://yarnpkg.com/getting-started/qa

     

    Questions & Answers | Yarn

    A list of answers to commonly asked questions.

    yarnpkg.com