Member-only story

npm ci vs. npm install — Which Should You Use in Your Node.js Projects?

Let’s learn some thing new, which is very useful for you for developement.

npm install,

  • 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.

npm ci,

  • 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. It does however expect a package-lock.json file in your project — if you do not have this file, npm ci will not work and you have to use npm install instead.
  • npm ci is fast — in some cases, twice as fast as using npm i.

Which to Use?

  • Use npm install to install new dependencies, or to update existing dependencies
  • Use npm ci when running in continuous integration, or if you want to install dependencies without modifying the package-lock.json.

Summary

  • npm i, can update your package-lock.json
  • npm ci , package-lock.json to install all the dependencies with the exact version.

Keep learning, Keep growing!

Let’s connect on LinkedIn!
Don’t forget to follow me on medium for more updates.

--

--

Sonika | @Walmart | Frontend Developer | 11 Years
Sonika | @Walmart | Frontend Developer | 11 Years

No responses yet