npm: Node Package Manager
CLI
npm init: 프로젝트 초기화npm install: package.json의 패키지를 현재 프로젝트(local. node_moduels)에 설치–ignore-scripts스크립트 실행 차단(공급자 공격 방지)–save package: 패키지를 프로젝트 의존성(dependencies)으로 추가–save-dev package,-D package: 패키지를 프로젝트 개발 의존성(devDependencies)으로 추가. 운영빌드시 배포안됨–save-prod package,-P package: 패키지를 프로젝트 운영으로 추가.–global,-g: 패키지를 전역 수준으로 추가.–legacy-peer-deps: 기존 버전을 다 무시하고 설치–force: package-lock.jso에 몇가지 다른 의존 버전들을 추가하면서 설치
npm uninstall -save pakcage: 패키지 삭제npm update –save: 프로젝트 패키지 업데이트npm ci의존성 설치(고정)npm run script_name: package.json의 scripts에 지정 명령 실행npm run startnpm cache clean: 캐시 삭제npm exec: 패키지 실행 npxnpm fund: 의존성 트리 확인npm config: 설정 확인npm config set KEY VALUE설정npm config get KEY확인npm config delete KEYnpm config list–json
CRA (create-react-app)
(depreated)
npm start: Starts the develpoment server.npm run build: Bundles the app into sttic files for production.npm test: Starts the test runner.npm run eject: 숨겨져 있는 설정 파일을 밖으로 내보냄(롤백불가) Removes this tool and copies build dependencies, configuration files and scripts into the app directory. If you do this, you can’t go back!
Frequently used commands
npm install –global <color #7092be>npm@latest: npm 업데이트npm init PACKAGE:create-가 붙은 패키지를 검색(npx create-PACKAGE)npm init vite:create-vite를 통한 vite 구성(npx create-vite)npm init vue@latest:create-vue를 통한 vue 구성(npx create-vue)npm init next:create-next-app를 통한 next 구성(npx create-next-app)
npm create vite@latest {path} – –template react: vite를 통한 react를 path에 생성(create-react-app 중지됨)