npm
Node.js 기본 패키지 매니저이자 레지스트리 클라이언트. 패키지 설치, 스크립트 실행, 설정 관리, 배포 흐름에 사용한다.
Summary
- 로컬 프로젝트 의존성 관리, 스크립트 실행, 레지스트리 인증, 배포 명령을 제공한다.
- 이 페이지의 로컬 help 출력은 2026-06-26 기준
npm 11.15.0에서 확인했다.
Usage
npm install npm install react npm ci npm run build
npm install [PACKAGE…] [<switches>…]npm uninstall PACKAGE…npm cinpm run SCRIPTnpm exec COMMANDnpm config set KEY VALUE
Options
-D,–save-dev:devDependencies에 저장한다.-P,–save-prod:dependencies에 저장한다.-O,–save-optional:optionalDependencies에 저장한다.-g,–global: 전역 설치/실행 흐름에 사용한다.–ignore-scripts: lifecycle script 실행을 막는다.–foreground-scripts: script 로그를 전면에 출력한다.–legacy-peer-deps: peer dependency 충돌을 느슨하게 처리한다.–force: 캐시나 충돌 검사를 우회할 수 있으므로 주의한다.–workspaces,-w: workspace 범위 실행에 사용한다.–json: 기계 처리용 JSON 출력.
Examples
npm init -y npm install npm install react npm install -D typescript vite npm install -g npm@latest npm ci npm run dev npm run build npm exec vite -- --host npm outdated npm fund npm cache clean --force npm config get registry npm config set fund false npm create vite@latest my-app -- --template react npm init vue@latest npm init next@latest
Config
- 주요 설정 파일:
package.json,package-lock.json,.npmrc - 사용자 설정 경로 예시:
~/.npmrc npm config get registry: 현재 registry 확인npm config set registry https://registry.npmjs.org/: registry 설정npm pkg get/npm pkg set:package.json필드 조작
Troubleshooting
- CI에서는
npm install보다npm ci가 lockfile 재현성과 속도 면에서 안전하다. - peer dependency 충돌은 먼저 버전 정합성을 맞추고, 마지막 수단으로만
–legacy-peer-deps를 사용한다. - global 설치 권한 오류가 나면 root 대신 사용자별 Node 버전 관리자(nvm 등) 사용을 우선 검토한다.
–ignore-scripts는 공급망 방어에 유용하지만, native package 초기화가 누락될 수 있다.
Compatibility
- 로컬 확인 버전:
npm 11.15.0 - npm 공식 명령 목록은 2026-06-26 기준
https://docs.npmjs.com/cli/v10/commands/와 로컬npm –help를 함께 확인했다. - npm major 버전이 바뀌면
exec,query,sbom,trust같은 서브커맨드 구성이 달라질 수 있다.
Deprecated / Legacy
만 단독 사용하던 오래된 문맥은 최신 버전에서npm cache cleannpm cache clean –force형태를 주로 본다.create-react-app기반 초기화는 사실상 legacy 흐름으로 취급하고, 새 프로젝트는npm create vite@latest,npm init vue@latest,npm init next@latest같은 도구를 우선한다.- CRA의
npm run eject는 되돌리기 어려운 legacy 절차로 남겨둔다.
Related
See Also
Help
History
- codex:: 2026-07-19 Updated Bun links to the
node.js:bun:kohead-page address. - codex:: 2026-06-26 Rebuilt npm page into structured CLI reference with install, exec, config, workspace, and legacy CRA notes.