C.W.K.
Stream
Lesson 03 of 05 · published

매일 치는 Yarn Berry 명령

~11 min · yarn, commands, workflow

Level 0초심자
0 XP0/55 lessons0/16 achievements
0/80 XP to next level80 XP to go0% complete

Berry 의 CLI 가 npm/pnpm 과 비슷하지만 의도적 rename 있음. 작은 차이 외워두면 머슬메모리 transfer.

yarn add <pkg> 가 런타임 dep 추가. yarn add --dev <pkg> (참고: --dev, -D 아님) 가 dev dep. yarn remove <pkg> 가 제거. yarn install 이 모든 거 install; yarn install --immutable 이 Berry 의 npm ci 등가물 — strict, CI 친화, lockfile 변경되면 fail.

yarn up <pkg> 가 패키지 업그레이드 (Berry 특화 동사; npm/pnpm 은 upgrade 사용). yarn upgrade-interactive 가 어느 패키지 bump 할지 고를 TUI 열기.

yarn dlx <tool> 가 install 없이 도구 실행 — Berry 의 npx. yarn workspaces foreach run build 가 모든 workspace 패키지에 스크립트 실행; yarn workspaces list 가 enumerate.

yarn node script.js 가 PnP 런타임 주입된 Node 실행 — PnP 코드가 셋업 없이 plain node 아래 못 돌기 때문에 필요. (.yarnrc.yml 에 nodeLinker: node-modules 로 PnP 비활성화하면 plain node 잘 작동.)

Code

매일 Berry 명령·bash
# 추가 / 제거
yarn add express
yarn add --dev vitest typescript
yarn remove express

# Install
yarn install
yarn install --immutable    # CI 모드 (npm ci 등가물)

# 스크립트 실행
yarn build
yarn test
yarn dev

# install 없이 도구 실행
yarn dlx create-vite my-app

# 인터랙티브 업그레이드
yarn upgrade-interactive
Workspaces — first-class monorepo·bash
# Berry monorepo 에서 (workspaces 는 package.json 에 선언)
yarn workspaces list

# 모든 workspace 에 'build' 실행
yarn workspaces foreach run build

# 'web' workspace 에서만 'dev' 실행
yarn workspace web run dev

# 특정 workspace 에 dep 추가
yarn workspace web add react

External links

Exercise

Berry 프로젝트에서 'yarn dlx create-vite my-app' 돌려. 그 다음 'cd my-app && yarn install --immutable'. 결과 .yarn/ 디렉토리 들여다봐 — 캐시, releases, PnP on 이면 unplugged 폴더 봐. 각 조각이 이유 있음; docs 가 각각 설명.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.