Analytics Vidhya
Published in

Analytics Vidhya

Speed up your Node CI Pipelines

Today we’re going to talk about a small improvement that can make our node pipelines much faster.

Photo by CHUTTERSNAP on Unsplash

A few days ago I came across an npm command I had never read or heard of. Until then, I used npm install to prepare the environment with all dependencies in my continuous integration piplines. But after I had dealt with it a little bit and test it out, I was impressed. The pipelines were more than 30% faster.

before and after I changed to npm ci

npm ci

The command I am talking about is, as you can read in the headline, npm ci. But what does it actually do? Why is it so much faster? And what are the differences to npm install? Below you can see a list of the most important differences between npm install and npm ci.

  1. npm ci ignores the specified dependencies in package.json and only installs the dependencies from the package-lock.json file.
  2. If package.json and package-lock.json do not contain the same dependencies, an error is returned. The npm install command, on the other hand, would adjust the package-lock.json file.
  3. If a node_modules folder already exists, through npm ci it’ll be removed and completely recreated.
  4. The package.json and package-lock.json are frozen. Both will not change.

Through all that I listed above and more, npm ci is much faster than npm install. I can recommend everyone to try it in their ci. Not only because of the time improvement. Also because of the fact that an error is thrown if the package.json and package-lock.json don’t contain the same dependencies.

Final thoughts

Today we talked about npm ci and the difference to npm install. I hope the short article was helpful and you were able to take something away. If you have any questions or notes, please leave them in the comments.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store