Difference between npm i and npm ci
NodeJSThanks to the very large open-source community around Node, it is possible for us to access many features already coded for us and install them very easily as dependencies in our projects.
npm is a Node package manager which will allow us to download, install, uninstall or update our packages within a project using its CLI.
npm ci
is very useful in CI/CD pipelines, but what is the differences with npm install
?
npm i
This is an alias for
npm install
The npm i
command is used to install all dependencies
or devDependencies
from a package.json file.
Syntax:
npm i
npm ci
CI means Continuous Integration
This command is similar to npm i
, except it's meant to be used in automated environments such as test platforms, continuous integration, and deployment. (Or any situation where you want to make sure you're doing a clean install of your dependencies).
npm ci
is used to install all exact versions of dependencies
or devDependencies
from a package-lock.json file.
Syntax:
npm ci
Differences between npm i and npm ci
npm i | npm ci |
---|---|
It is slower in execution | It is faster in execution |
The project just need a package.json | The project must have an existing package-lock.json |
It may write to package.json or package-lock.json | It will never write to package.json or package-lock.json: installs are essentially frozen. |
Individual dependencies can be added | Individual dependencies cannot be added |
If any dependency is not in package-lock.json, npm i will add it | If dependencies in the package-lock.json do not match those in package.json, npm ci will exit with an error, instead of updating the package-lock.json |
If a node_modules is already present, npm i doesn’t change anything to it | If a node_modules is already present, it will be automatically removed before npm ci begins its install |
It can install global packages | It can not install global packages |
See official documentations :
Back to Top