Reputation: 1
With GitLab I can cache node_modules/
and/or I can cache the argument to npm ci --cache <dir>
What's the difference between these two options?
node_modules/
between jobs and stages in my pipeline?<dir>
provided to npm ci --cache
The GitLab docs show:
npm ci --cache .npm --prefer-offline
But they don't explain why I would not want to cache node_modules/
.
Size difference:
❯ du -hs .npm
136M .npm
❯ du -hs node_modules
932M node_modules
Upvotes: 5
Views: 4366
Reputation: 1
The difference in my case was massive, by NOT caching node_modules/
I reduced my CI pipeline timing between 30-50%.
It's faster to have every stage include
npm ci --cache .npm --prefer-offline
Then it is to move around node_modules/
with a GitLab cache layer.
I suppose the data may work out differently if not using containerized runners.
Upvotes: 3