How to generate package-lock.json in nodejs forcibly with npm
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 .npmrc
file for package-lock
settings.
It is a global node configuration that applies to running OS.
package-lock=false
Globally,if package-lock
is false
, It won’t generate package-lock.json
. by setting the package-lock
to true
, It generates the package-lock.json file automatically on the npm install command.
Locally, You can also override and run changing this with the command line
npm config set package-lock true
package-lock.json
is introduced from NodeJS version 5.x, It contains all direct and indirect dependencies of a node application.
First, run the npm install
command.
npm install
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?
To update package-lock.json file without npm install command, Please run below command
npm install --package-lock-only
It updates the package-lock.json
file without checking package dependencies in package.json and downloading dependencies.
It works only since node 5.x version.