NPM(Node Package Manager)은 전 세계의 개발자들이 만든 다양한 패키지, 모듈을 관리 한다.
package.json 이 생성 된다.
npm init -y
node_modules, package-lock.json 파일이 생성된다.
npm install parcel-bundler -D
npm install lodash
npm 을 install 하면 package.json 의 devDependencies, dependencies 에 추가된다.
{
"name": "test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"parcel-bundler": "^1.12.5"
},
"dependencies": {
"lodash": "^4.17.21"
}
}
node_modules 파일을 삭제해도 package.json 에 명시되어져 있는 내용을 바탕으로 다시 설치 할
수 있다.
$ npm i
$ npm install parcel-bundler -D
$ npm install lodash
-D 가 붙었다면 devDependencies
붙지 않았다면 dependencies
에 명시된다.
개발용 의존성 패키지
devDependencies : 개발 할 때만 필요하고 웹 브라우저에서는 필요하지 않다.
일반 의존성 패키지
dependencies : 웹 브라이저에서 동작해야 할 수도 있다.