Skip to content

node_modules caching is harmfull when using npm ci #75

@WolfSoko

Description

@WolfSoko

Beside caching node_modules with your caching workflow step the Agents for my repo needed always too long (4mins) to run the install-node-modules action.

The problem comes from the usage of npm ci to install node_modules based on the package-lock.json:

In an CI environment using npm ci sound correct, but the upfront caching of node_modules folder makes no sense at all.
It even takes more time because due to npm documentation npm ci deletes the node_modules folder for a clean installation process. @see npm ci documentation what takes more time when the folder is filled after a cache hit.

What can be cached to speed up npm ci is the global node cache $HOME/.npm from which npm ci can pull the packages faster.

I created my agents based on your runner templates. So I guess a lot of people are facing the same problem.

As a workaround I just replaced my usage of your install-node-modules workflow-step with a simple script that just runs npm install.
It brought down the execution time to 4sec when hitting the cache!
Fast execution was more important for me then consistency of the dependencies.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions