How to install dependencies from package-lock.json
Normally you would install dependencies using the npm install
command. This command will install the dependencies from the package.json
file. This file contains the dependencies that are required for the application to run.
The package-lock.json
file is a file generated by npm to lock down the versions of the dependencies that are installed. This file is used to ensure that the same versions of dependencies are installed on all machines that are used to develop and run the application.
Using this as base for an installation is quite easy. Just run the following command:
npm ci
This will install the dependencies from the package-lock.json
file. If the file does not exist, it will fail.
The cousin of npm
is yarn
. Yarn has a similar command to install dependencies from a lock file:
yarn install --frozen-lockfile
For more information on yarn’s own lock file yarn.lock
, see: yarn.lock