DEV Community

Cover image for Difference between "npm i" and "npm ci"
Akash Yadav
Akash Yadav

Posted on

Difference between "npm i" and "npm ci"

Basically, npm install reads **package.json **to create a dependency list and uses package-lock.json to specify which dependency versions to install. If the dependency is not in the package-lock.json file, it will be added via npm install.

npm ci (also known as Clean Install) is designed to be used in an automated environment such as testbench, integration and continuous deployment, or any situation where you want clean development of dependencies. .

Loads dependencies directly from package-lock.json and uses only package.json to ensure there are no conflicts in dependencies. If a dependency is missing or the version is incompatible, an error is thrown.

Use npm install to add dependencies and update the project's dependencies. Most of the time you will use this during development after downloading the changes that update your progress, but using npm ci this way may be a good idea.

Again, use npm ci if you want a decision. For example, continuous integration, automatic operation, etc. in the process. And while it installs successfully the first time, npm install does not.

npm install
Install the package and all its dependencies.
Dependencies are driven by npm-shrinkwrap.json and package-lock.json (in that order).
Unlimited: Fix dependencies of native module.
International packages can be installed.
All missing dependencies will be placed in node_modules.
Can be written to package.json or package-lock.json file. When used with the
(npm i packagename) parameter, it can be written to the package.json file to add or update dependencies.
When used without arguments (npm i), some dependencies can be written to the package-lock.json file to lock their structure if they are not already in this file.< br>

npm ci
Minimum Required npm v5 . 7.1.
package-lock.json or npm-shrinkwrap.json must be present.
Returns an error if the dependencies of the two files are not related to package.json.
Remove node_modules and install all dependencies now.
Never writes to package.json or package-lock.json.

Top comments (0)