When using 'actions/setup-node' with 'cache: npm', what files does it use to generate the cache key?
Select an answer to reveal the explanation.
Short Explanation and Infographic
setup-node's built-in caching hashes the lock file — package-lock.json for npm, yarn.lock for yarn, pnpm-lock.yaml for pnpm.
Full explanation below image
Full Explanation
actions/setup-node with 'cache: npm' automatically sets up caching of the npm cache directory using a key derived from the hash of the lock file. For npm, it looks for package-lock.json or npm-shrinkwrap.json. For yarn (cache: 'yarn'), it uses yarn.lock. For pnpm (cache: 'pnpm'), it uses pnpm-lock.yaml. The action uses the OS and Node version in the cache key as well. This built-in caching is simpler than manually configuring actions/cache for npm. The node_modules directory itself is sometimes cached but is typically faster to reinstall from a cached npm store.