npm ci command | only refer package-lock.json to install dependencies | ci/cd

  • There is a package-lock.json or npm-shrinkwrap.json file.
  • The node_modules folder is missing or empty.
  • It will install all the dependencies.
  • If you use ^ or ~ when you specify the version of your dependency, npm may not install the exact version you specified.
  • npm install can update your package-lock.json when there are changes such as when you install a new dependency.
  • The project must have an existing package-lock.json or npm-shrinkwrap.json.
  • If dependencies in the package lock do not match those in package.json, npm ci will exit with an error, instead of updating the package lock.
  • npm ci can only install entire projects at a time: individual dependencies cannot be added with this command.
  • If a node_modules is already present, it will be automatically removed before npm ci begins its install.
  • It will never write to package.json or any of the package-locks: installs are essentially frozen.
  • It will delete your node_modules folder to ensure a clean state.
  • It will look in your package-lock.json to install all the dependencies with the exact version.
  • Unlike npm install, npm ci will never modify your package-lock.json.
  • Use npm install to install new dependencies, or to update existing dependencies (e.g. going from version 1 to version 2).
  • Use npm ci when running in continuous integration, or if you want to install dependencies without modifying the package-lock.json.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store