package-lock.json files are generated automatically while running npm install or npm update.
It also generates any changes to the recursive node_modules folder tree.
Sometimes, the developer deletes this or only wants to update this file.
This post shows you many ways to generate or update the package-lock.json file in NodeJS.
However, this can be disabled in the
.npmrc settings file with package-lock=false.
Please check the home directory
.npmrcfile for package-lock settings.
It is a global node configuration that applies to running OS.
if package-lock is false, It won’t generate package-lock.json. by setting the package-lock.json file, It generates the package-lock.json file automatically on the npm install command.
You can also run changing this with the command line
npm config set package-lock true
package-lock.json is introduced from NodeJS version 5. x and It contains all direct and indirect dependencies of a node application.
First, run the npm install command.
It generates a package-lock.json file in the node directory.
Sometimes, You want to generate a package-lock.json file without npm install. How to do it?
How to update package-lock.json without doing npm install?
Run below command
npm install --package-lock-only
It updates the package-lock.json file without downloading package dependencies.
It works only since node 5. x version.