The difference between package.json and package-lock.json needs to be ignored by the .gitignore file

foreword

  • First, we need to figure out what are the functions of the package.json and package-lock.json files

  • What is the .gitignore file for - the main page article has

introduce

package.json

1. Project name version number, description, and run commands and some configured node environment commands

2. Record which packages will be used in the development environment, which packages will be used in both the development environment and the production environment

3. When npm i downloads the package, it will record the package in different environment folders according to -D -S

4. For npm i, it is installed in dependencies by default, which means it will be used in both production and development.

grammar specification

 

package-lock.json

1. Record the specific version of the package, the download address, and some basic information

.gitignore file ignore

When developing for a team, git provides a way to eliminate useless files to facilitate shared management codes. Because the code is very small, the third-party package mainly takes up space

Summarize:

1. Whether package-lock.json should be placed in the .gitignore ignore file depends on the code specification and requirements.

2. package.json cannot be ignored, ackage-lock, json depends on the situation (whether the specific version of package.json is determined) and requirements (company specifications) to ignore

2. package.json controls the major version, package-lock, json controls the minor version. If there is no package-lockjson, the dependency will install the version of the package according to the syntax specification of the package.json file. If there is package-lockjson, both major and minor versions can be controlled


Summarize:

After this process, I believe you have a preliminary deep impression on whether the difference between package.json and package-lock.json needs to be ignored by the .gitignore file, but the situation we encounter in actual development must be different. , so we have to understand its principle, and it is always the same. Come on, hit the workers!

Please point out any deficiencies, thank you -- Fengguowuhen

Guess you like

Origin blog.csdn.net/weixin_53579656/article/details/131117225