npm install vs npm ci

Posted on

npm ci is a new npm command introduced in npm 6. Let's see how this command is different with npm install

NPM CI

npm ci characteristics:

npm ci will always delete node modules npm ci delete node module

npm ci will throw error if version is different in package.json vs package-lock.json npm ci different package version

NPM Install

npm install characteristics:

For example, the version in package.json is ~4.17.0, but after running npm install, in package-lock.json, it will use 4.17.20 (the latest patch version)

npm install different version

Conclusion

Use npm ci for automated environment such as CI/CD while npm install to install a new dependency or update dependencies.