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 install2. 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.
Here are the corresponding fields of package.json of one of my projects;
You can see that the npm package name and version number are recorded, which ensures that everyone’s environment is unified. Finally, the person responsible for the basic configuration of the project initializes the project:
Use package.json to manage your npm packages
Here are the corresponding fields of package.json of one of my projects;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.jsonThe two fields devDependencies
anddependencies
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.You can see that the npm package name and version number are recorded, which ensures that everyone’s environment is unified. Finally, the person responsible for the basic configuration of the project initializes the project:
to add the corresponding package name and version.npm install
命令时添加--save
,会自动去package.json中的dependencies
Use
to add the corresponding package name and version.npm install
命令时添加--save-dev
,会自动去package.json中的devDependencies
Use