Cache the node_modules directory across builds in Jenkins. In our project, we do not remove the node_modules directory entirely per branch build. Removing it would result into download and installing packages again and again per branch build. I have seen developers getting bashed by the Dev-ops lead for doing back-door using docker-file and removed node_modules for some (hidden)specific reason 😄.
This can be a funny one but you can try,
npm set progress=false
npm install
Setting the appearance of install progress-bar reduces the time taken to install.
I have heard and read about npm ci but never used it. It uses package-lock.json file to skip building your dependency tree off of your package.json file, honoring the already resolved dependency URLs in your lock file. Downside is that, npm ci removes the node_modules/ directory before installing, so it won't benefit from the caching strategies, I was talking about in my first point.
I shall also check with my dev-ops lead when in office tomorrow and update you if there are anything else that can help here ☺️.
You may think about using Yarn instead as it installs packages in parallel instead of sequentially like npm which makes it noticeably faster on most installs.
Tapas Adhikary
Educator @tapaScript | Founder CreoWis & ReactPlay - Writer - YouTuber - Open Source
Manohar Srinivasa,
Couple of ways that I can think of are:
Cache the
node_modulesdirectory across builds in Jenkins. In our project, we do not remove thenode_modulesdirectory entirely per branch build. Removing it would result into download and installing packages again and again per branch build. I have seen developers getting bashed by the Dev-ops lead for doing back-door using docker-file and removed node_modules for some (hidden)specific reason 😄.This can be a funny one but you can try,
npm set progress=false npm installSetting the appearance of install progress-bar reduces the time taken to install.
I have heard and read about
npm cibut never used it. It usespackage-lock.jsonfile to skip building your dependency tree off of your package.json file, honoring the already resolved dependency URLs in your lock file. Downside is that,npm ciremoves the node_modules/ directory before installing, so it won't benefit from the caching strategies, I was talking about in my first point.I shall also check with my dev-ops lead when in office tomorrow and update you if there are anything else that can help here ☺️.