Join my Laravel for REST API's course on Udemy 👀

Generate only a package-lock.json file with npm

April 13, 2022  ‐ 1 min read

The package-lock.json file is a useful tool for installing packages in a continuous integration environment.

Normally the package-lock.json file gets updated whenever you run npm install.

If you wish to locally generate a new package-lock.json without installing or updating the dependencies you can use a special option to the npm install command.

Since npm version 6, don’t confuse this with your node.js version, you can use the --package-lock-only option to create a new lock file.

$ npm install --package-lock-only

Using this option won't install new node modules, even though using the install subcommand does suggest so.

To find out which npm version you are using you can use:

$ npm --version