GitHub Actions setup-node/setup-python Cache Not Restoring Dependencies
The cache: option on setup-node or setup-python is not speeding up installs because no lockfile was found, the dependency path is wrong, or you expected it to cache the installed tree rather than the package-manager cache.
What this error means
A setup step warns that no lockfile or cache folder was found, and dependency installs run cold every time despite enabling cache:.
Warning: Some specified paths were not resolved, unable to cache dependencies.
# no package-lock.json found at the expected pathCommon causes
Lockfile missing or in a subdirectory
setup-* hashes a lockfile to key the cache. If none exists at the root, or it lives in a subdirectory, the action cannot resolve a cache.
Caches the manager cache, not node_modules
setup-node caches the npm/yarn/pnpm download cache, not node_modules. You still run install; it is just faster. Expecting a fully populated node_modules causes confusion.
How to fix it
Point cache at the right lockfile
Set cache and cache-dependency-path so the action finds the lockfile to hash.
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
cache-dependency-path: app/package-lock.jsonStill run install, or cache node_modules yourself
- Keep an npm ci / pip install step - setup-* warms the download cache, it does not skip install.
- To cache the installed tree, use actions/cache on node_modules directly with a lockfile-hash key.
- Commit the lockfile so the cache key is stable.
How to prevent it
- Commit a lockfile and point cache-dependency-path at it.
- Understand setup-* caches the package-manager cache, not node_modules.
- Use actions/cache directly when you need to cache installed dependencies.