Using webpack requires installing many loaders and npm packages. Do I need to upload the node_modules directory when managing git? Is this directory too big? But if it is not uploaded, does everyone involved in the development need to download the loaders themselves?
淡淡烟草味2017-05-02 09:40:47
Use package.json to manage your npm packages
1. Use npm init
to initialize the package.json configuration file when initializing the project; npm init
初始化package.json配置文件;
2、package.json里面有两个字段devDependencies
和dependencies
两个字段分别表示开发环境需要的npm包和部署环境需要的npm包。
3、同步代码的时候大家只需要同步一下package.json文件,然后执行npm install
2. There are two fields in package.json The two fields devDependencies
and dependencies
respectively represent the npm packages required by the development environment and the npm packages required by the deployment environment.
3. When synchronizing code, you only need to synchronize the package.json file, and then execute the npm install
command. npm will automatically retrieve the configuration in package.json and install the corresponding node_modules.
"dependencies": {},
"devDependencies": {
"babel-preset-es2015": "^6.6.0",
"gulp": "^3.9.1",
"gulp-babel": "^6.1.2",
"gulp-concat": "^2.6.0",
"gulp-connect": "^2.3.1",
"gulp-minify-css": "^1.2.3",
"gulp-sass": "^2.1.1",
"gulp-uglify": "^1.5.1",
"shelljs": "^0.7.0"
}
npm install
命令时添加--save
,会自动去package.json中的dependencies
Use
npm install
命令时添加--save-dev
,会自动去package.json中的devDependencies
Use