콘텐츠로 이동

npm 패키지 관리자

JavaScript 및 Node.js 개발을 위한 종합 npm (Node Package Manager) 명령 및 워크플로우.

설치 및 설치

Node.js 및 npm 설치

카지노사이트

기본 패키지 작업

Command Description
npm install package_name Install package locally
npm install -g package_name Install package globally
npm uninstall package_name Uninstall package
npm update Update all packages
npm update package_name Update specific package
npm list List installed packages
npm list -g List global packages

프로젝트 관리

프로젝트 초기화

Command Description
npm init Initialize new project
npm init -y Initialize with defaults
npm init @scope Initialize with scoped template
npm create package_name Create project with template

의존성 관리

Command Description
npm install Install all dependencies
npm install --save package Install and save to dependencies
npm install --save-dev package Install and save to devDependencies
npm install --save-optional package Install as optional dependency
npm install --no-save package Install without saving

패키지 정보

Command Description
npm search keyword Search for packages
npm info package_name Show package information
npm view package_name View package details
npm outdated Show outdated packages
npm audit Check for vulnerabilities
npm audit fix Fix vulnerabilities

스크립트 및 실행

Script 관리

Command Description
npm run script_name Run custom script
npm start Run start script
npm test Run test script
npm run build Run build script
npm run dev Run development script

예제 패키지.json 스크립트

카지노사이트

버전 관리

Semantic 버전

Command Description
npm version patch Increment patch version
npm version minor Increment minor version
npm version major Increment major version
npm version prerelease Create prerelease version

패키지 설치 by Version

Command Description
npm install package@1.2.3 Install specific version
npm install package@latest Install latest version
npm install package@next Install next/beta version
npm install package@^1.2.0 Install compatible version

제품 설명

npm 설정

Command Description
npm config list Show configuration
npm config get key Get configuration value
npm config set key value Set configuration value
npm config delete key Delete configuration

일반 설정

Setting Description
npm config set registry https://registry.npmjs.org/ Set registry
npm config set init-author-name "Your Name" Set default author
npm config set init-license "MIT" Set default license
npm config set save-exact true Save exact versions

.npmrc 파일

카지노사이트

회사연혁

패키지 출판

Command Description
npm login Login to npm registry
npm whoami Check logged in user
npm publish Publish package
npm publish --access public Publish scoped package publicly
npm unpublish package@version Unpublish specific version

출판 Workflow

카지노사이트

고급 사용

작업 공간 (오후 7+)

카지노사이트

Command Description
npm install --workspaces Install all workspace dependencies
npm run test --workspaces Run tests in all workspaces
npm run build --workspace=package-a Run command in specific workspace

패키지 링크

Command Description
npm link Create global link
npm link package_name Link to global package
npm unlink package_name Unlink package

Cache 관리

Command Description
npm cache verify Verify cache integrity
npm cache clean --force Clear cache
npm cache ls List cached packages

계정 관리

보안 감사

Command Description
npm audit Check for vulnerabilities
npm audit --audit-level high Check high severity only
npm audit fix Fix vulnerabilities automatically
npm audit fix --force Force fix (may break changes)

패키지 검증

Command Description
npm pack Create tarball
npm pack --dry-run Show what would be packed
npm install package.tgz Install from tarball

성능 최적화

빠른 임명

카지노사이트

관련 패키지 관리자

Manager Installation Benefits
Yarn npm install -g yarn Faster, deterministic
pnpm npm install -g pnpm Disk space efficient
Bun curl -fsSL https://bun.sh/install \|bash Extremely fast

문제 해결

일반적인 문제

Problem Solution
Permission errors Use nvm or fix permissions
Package conflicts Delete node_modules and reinstall
Outdated npm npm install -g npm@latest
Registry issues npm config set registry https://registry.npmjs.org/

관련 링크

Command Description
npm doctor Check npm environment
npm ls Check dependency tree
npm ls --depth=0 Show top-level dependencies
npm why package_name Show why package is installed

재설정 및 클린 설치

카지노사이트

최고의 연습

패키지.json 회사연혁

카지노사이트

개발 Workflow

  1. **Version Pinning **: 긴 수명을 위한 정확한 버전 사용
  2. Lock Files : 버전 컨트롤에 패키지-lock.json을 시작합니다.
  3. 보안: npm audit의 정기적 보안 감사
  4. 명세 테스트: npm pack로 발행하기 전에 테스트
  5. 명세 문서: 종합문서 유지

- 연혁

  1. CI/CD: 지속적인 통합에 있는 npm ci를 사용하십시오
  2. Caching: CI 환경에서 npm 캐시 레버리지
  3. ** 선택 설치 **: 사용 --production 생산 빌드
  4. 명세 Alternative Managers: 큰 프로젝트에 대한 원사 또는 pnpm 고려
  5. 명세 Registry: 내부 패키지에 대한 개인 레지스트리 사용