"매 scripts는 package.json 의 entry point 인 명령어 alias". npm run <name> 으로 실행되며, dev/build/test/lint/deploy 등의 lifecycle automation 을 정의. 2026 기준 npm/pnpm/bun/yarn 호환, 매 monorepo 에서는 turbo/nx 가 orchestration.
매 핵심
매 lifecycle
pre/post: prebuild → build → postbuild 자동 실행
special names: start, test, install, prepare
arbitrary: 매 다른 이름 은 npm run <name>
매 cross-platform
cross-env, rimraf, mkdirp 등으로 OS 차이 흡수
매 modern 대안: zx, execa, tsx-based scripts
매 응용
Local dev: dev, build, test, lint.
CI: ci:test, ci:build, ci:deploy.
Tooling: typecheck, format, analyze.
Release: release, publish:dry.
💻 패턴
Modern package.json scripts
{"scripts":{"dev":"next dev --turbo","build":"next build","start":"next start","lint":"biome check .","lint:fix":"biome check --write .","typecheck":"tsc --noEmit","test":"vitest","test:e2e":"playwright test","test:coverage":"vitest run --coverage","format":"biome format --write .","clean":"rimraf .next dist coverage","prepare":"husky","release":"changeset publish"}}
Pre/post hooks
{"scripts":{"prebuild":"npm run typecheck && npm run lint","build":"tsc -p tsconfig.build.json","postbuild":"node scripts/copy-assets.mjs"}}