Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is package-lock.json?

Is there any kind-teacher can answer my question above?

FYI I'm using WebStorm and making with node.js I installed npm module like nconf and package-lock.json has made. I expected package.json would've been made.

Thank you.

like image 897
jinuman Avatar asked Aug 23 '17 13:08

jinuman


People also ask

What is Package lock json used for?

lock. json is created for locking the dependency with the installed version. It will install the exact latest version of that package in your application and save it in package.

Should I delete package lock json?

package-lock. json defines versions used in my project. There should be no need to remove it completely and thus upgrade all dependencies to the latest version just because I upgrade Vaadin.

Can I delete package lock json and install it again?

json that result in two different installs. You may have noticed it before; you install a package using npm and suddenly a new file called package-lock. json appears in your project directory. Don't delete that package-lock file, run npm install and regenerate it!


1 Answers

Describe the dependency tree in a given moment, so with this description all the dependencies can be created again exactly the same way it was, this ensures the expected behavior from the dependencies.

In the npm documentation you can read:

package-lock.json is automatically generated for any operations where npm modifies either the node_modules tree, or package.json. It describes the exact tree that was generated, such that subsequent installs are able to generate identical trees, regardless of intermediate dependency updates.

This file is intended to be committed into source repositories, and serves various purposes:

Describe a single representation of a dependency tree such that teammates, deployments, and continuous integration are guaranteed to install exactly the same dependencies.

Provide a facility for users to "time-travel" to previous states of node_modules without having to commit the directory itself.

To facilitate greater visibility of tree changes through readable source control diffs.

And optimize the installation process by allowing npm to skip repeated metadata resolutions for previously-installed packages.

like image 125
Óscar Andreu Avatar answered Oct 02 '22 23:10

Óscar Andreu