NPM Install vs. NPM CI

Introduction 

 
In this article, we will see the main differences between NPM Install and NPM CI. 

npm install

  • npm install (or npm i) is used to install all dependencies (dependencies or devDependencies) from a package.json file
  • npm install can update the package-lock.json file. If doesn't exist, it will create it

npm ci

  • npm ci is used to install all exact version dependencies (dependencies or devDependencies) from a package-lock.json file (even package.json is required)
CI means continuous integration, and it will follow the below steps;
  1. First, it will delete the node_module folder, if it exists.
  2. It will look package-lock.json to install all dependencies with the exact version.
  3. npm ci doesn't modify the package-lock.json file.

Summary

 
npm install - installs new dependencies or updates existing dependencies based on version (^,` or *) in a package.json file
 
npm ci - when you want to run continuous integration tools like Jenkins, TeamCity or GitLab CI, then use npm ci, which doesn't modify the package-lock.json file
Next Recommended Reading Introduction To NPM And Node.js