However, here's why you should always commit package-lock.json:
1:
This file describes in details the node_modules tree. It is different from package.json in that it describes in details everything npm needs to see about the installed modules. This is called metadata. And it's the only way to be 100% sure that all the team members have the exact same node modules and dependencies.
If this point is confusing that's fine, just be sure to commit the package-lock.json into your project's source files.
2:
If you want to go back to a certain branch you pushed previously, the only way to revert to it with the exact node_modules file you had when you pushed is either to have pushed the node_modules file or to have the file package-lock.json on github.
3:
It makes npm install command much faster and cleaner. Without this file, npm would have to reinstall the metadata every single time you write npm install.
https://github.com/FACG6/books-autocomplete/blob/05b6575b147d1e64971601b3af76ce41af0dd6c2/.gitignore#L3
qoute from FarahZaqout
However, here's why you should always commit package-lock.json:
1:
This file describes in details the
node_modules
tree. It is different frompackage.json
in that it describes in details everythingnpm
needs to see about the installed modules. This is calledmetadata
. And it's the only way to be 100% sure that all the team members have the exact same node modules and dependencies. If this point is confusing that's fine, just be sure to commit thepackage-lock.json
into your project's source files.2:
If you want to go back to a certain branch you pushed previously, the only way to revert to it with the exact
node_modules
file you had when you pushed is either to have pushed thenode_modules
file or to have the file package-lock.json on github.3:
It makes
npm install
command much faster and cleaner. Without this file,npm
would have to reinstall themetadata
every single time you writenpm install
.