본문 바로가기
C.W.K.
Stream
Lesson 02 of 13 · published

Node.js CI

~12 min · node, npm, pnpm

Level 0견습생
0 XP0/101 lessons0/10 achievements
0/120 XP to next level120 XP to go0% complete

런타임 고르고 버전 고정하기

요즘 쓸 만한 런타임은 Node.js(클래식), Deno, Bun 세 가지야. 대부분 프로덕션 앱은 아직 Node.js를 쓴다. 패키지 매니저는 npm(기본), pnpm(빠르고 content-addressed 방식), yarn(여전히 쓰임), bun(엄청 빠르고 런타임도 겸함)이 있다.

기본 Node CI 구성은 이렇게 흘러가:

  1. 저장소 체크아웃.
  2. actions/setup-node@v4로 버전 고정하고 패키지 매니저 캐시 설정.
  3. npm ci(또는 pnpm install --frozen-lockfile, yarn install --immutable, bun install)로 lockfile 기반 깔끔하고 재현 가능한 설치.
  4. 린트: eslintbiome.
  5. 타입 검사: tsc --noEmit.
  6. 테스트: vitest run, jest, 또는 node --test.

자주 겪는 함정

  • CI에서 npm install을 쓰면 안 돼. lockfile을 몰래 업데이트할 수 있거든. 무조건 npm ci를 써.
  • actions/setup-node의 기본 캐시 키는 lockfile 해시야. 모노리포에서 lockfile이 여러 개라면 cache-dependency-path:를 명시해.
  • 매트릭스 셀마다 npm install을 따로 돌리지 마. 버전이 다르지 않으면 매트릭스 간에 설치를 공유해.

Code

pnpm으로 Node CI·yaml
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: pnpm/action-setup@v4
        with: { version: 9 }
      - uses: actions/setup-node@v4
        with:
          node-version: '22'
          cache: pnpm
      - run: pnpm install --frozen-lockfile
      - run: pnpm lint
      - run: pnpm tsc --noEmit
      - run: pnpm test --run
bun으로 Node CI (속도 벤치마크)·yaml
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: oven-sh/setup-bun@v2
        with: { bun-version: latest }
      - run: bun install --frozen-lockfile
      - run: bun run lint
      - run: bun run test

External links

Exercise

Node 프로젝트에 캐시 두 단계로 CI 설정해 봐: actions/setup-node 기본 캐시(lockfile 기반) + .next/dist/ 빌드 출력 캐시. 콜드 실행과 웜 실행 시간을 재 봐.

Progress

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

댓글 0

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

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