npm 5 was released today and one of the new features include deterministic installs with the creation of a package-lock.json
file.
Is this file supposed to be kept in source control?
I'm assuming it's similar to yarn.lock
and composer.lock
, both of which are supposed to be kept in source control.
I don't commit this file in my projects. What's the point ?
Though it's true that i never use ^ in my package.json for libs because I had bad experiences with it :)
Regards.
To the people complaining about the noise when doing git diff:
what I did was use an alias
Disable package-lock.json globally
type the following in your terminal:
this really work for me like magic
Yes, the best practice is to check in
I agree that it will cause a lot of noise or conflict when seeing the diff. But the benefits are:
^1.2.3
in yourpackage.json
, but how can u ensure each timenpm install
will pick up the same version in your dev machine and in the build server, especially those indirect dependency packages? Well,package-lock.json
will ensure that. (With the help ofnpm ci
which installs packages based on lock file)npm audit fix
(I think the audit feature is from npm version 6).Yes,
package-lock.json
is intended to be checked into source control. If you're using npm 5, you may see this on the command line:created a lockfile as package-lock.json. You should commit this file.
According tonpm help package-lock.json
:Yes, it's intended to be checked in. I want to suggest that it gets its own unique commit. We find that it adds a lot of noise to our diffs.