Yes, it's a standard practice to commit package-lock.json
.
The main reason for committing package-lock.json
is that everyone in the project is on the same package version.
Pros:
- If you follow strict versioning and don't allow updating to major versions automatically to save yourself from backward-incompatible changes in third-party packages committing package-lock helps a lot.
- If you update a particular package, it gets updated in package-lock.json and everyone using the repository gets updated to that particular version when they take the pull of your changes.
Cons:
- It can make your pull requests look ugly :)
npm install
won't make sure that everyone in the project is on the same package version. npm ci
will help with this.