logo
Published on

Caching in GitHub Actions

Authors
  • avatar
    Name
    Bowen Y
    Twitter

How to speed up npm ci command?

npm ci should be preferred in CI because it respects the package-lock.json file. Unlike npm install, which rewrites the file and always installs new versions.

By design this command always purges all local packages, by removing the node_modules directory in the beginning. This is the main reason for long builds. And there is no option to avoid this irritating behaviour.

So the idea is not to cache the node_modules folder, but to cache the libs of npm.

https://github.com/actions/setup-node#caching-global-packages-data

https://stackoverflow.com/questions/55230628/is-there-a-way-to-speedup-npm-ci-using-cache