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.
- It will install all the dependencies.
- If you use
~when you specify the version of your dependency, npm may not install the exact version you specified.
npm installcan update your
package-lock.jsonwhen there are changes such as when you install a new dependency.
- It will delete your
node_modulesfolder to ensure a clean state.
- It will look in your
package-lock.jsonto install all the dependencies with the exact version.
npm ciwill never modify your
package-lock.json. It does however expect a
package-lock.jsonfile in your project — if you do not have this file,
npm ciwill not work and you have to use
- npm ci is fast — in some cases, twice as fast as using npm i.
Which to Use?
npm installto install new dependencies, or to update existing dependencies
npm ciwhen running in continuous integration, or if you want to install dependencies without modifying the
- npm i, can update your
- 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.