Saturday, 2 February 2019

Can I check the validity of node_modules without running npm install?

I’m optimizing the build pipeline for a fairly big react project and at the moment it takes 2-4 minutes to run the tests pipeline with 80% of it being in doing npm install.I already cached the node_modules folder in the CI runner, which drops the duration of npm install from 6-9 minutes to what it is now. But that’s still a lot of time just for checking if node_modules are okay because most of the time, the package.json is unchanged. In Go project I could just cache the vendor folder and run “dep check” and it’ll take 1 second to check if “dep ensure” (kind of like npm install, which also takes quite a lot of time) is needed to run.I’ve tried npm ci which should be faster but in my case, it’s just a lot slower.I’m thinking to make a conditional rule on the pipeline, if the committed package.json hasn’t changed since the last time AND if the last tests are successful, skip npm install. Can this work?

Submitted February 03, 2019 at 02:51AM by yondercode

No comments:

Post a Comment