Please note: there are many similar questions here however I do believe I am truly asking a new + unique question.
I am new to Node and JavaScript and I am trying to understand the different uses of package.json
and package-lock.json
. Before you read any further, no, I am not merely just asking for a summary of what their difference is here.
After doing some homework, my understanding of them is as follows:
- you want to commit both to source control, so neither should be mentioned in the
.gitignore
package.json
describes your project and can do some lightweight dependency management, for instance, specifying that you want the latest version of thefizzbuzz
package, or you want the latest3.10.x
version of thefizzbuzz
packagepackage-lock.json
is purely for dependency management and goes into detail about which specific dependencies your project should use; for instance if you specify you want the latest3.10.x
version offizzbuzz
in yourpackage.json
file, thepackage-lock.json
file might specifyfizzbuzz-3.10.24
, etc.- you do directly modify/edit your
package.json
file, but you only let NPM and perhaps other command line tools modify yourpackage-lock.json
(hence no human being should ever editpackage-lock.json
)
Are these statements correct? If not, can someone please provide some details as to how/where my understanding is going awry?