Help with cache restore

cache

#1

I am not able to restore caches for node_modules. I always see the cache is being unarchived but only 32 B:

Found a cache from build 702 at v3-dependencies-XxcbZ8eGx+t1hp1pzxOYUkcpH8394S0LYT_kjWxmGW0=
Size: 32 B
Cached paths:

  • /home/circleci/amio-webapp/.node_modules

Downloading cache archive…
Validating cache…

Unarchiving cache…

After that, npm is still installing all deps…

This is my configuration for cache (v3- is there vecause i tried to remove caches):

  - restore_cache:
      keys:
      - v3-dependencies-{{ checksum "package.json" }}
      - v3-dependencies-

  - run:
      name: Install Npm
      command: npm install

  - save_cache:
      key: v3-dependencies-{{ checksum "package.json" }}
      paths:
        - node_modules # I tried also with .node_modules

What am I doing wrong?

The last config that was working for me was surprisingly this (notice the incorrect save key dependency-cache-:

 - restore_cache:
      keys:
      - v1-dependencies-{{ checksum "package.json" }}
      # fallback to using the latest cache if no exact match is found
      - v1-dependencies-

  - run:
      name: Install Npm
      command: npm install

  - save_cache:
      key: dependency-cache-{{ checksum "package.json" }}
      paths:
        - .node_modules

#2

Do you have the output of the save_cache step to see what is happening there? Is it saving with a different key or perhaps skipping because the cache already exists for your key?
You could try changing the checksum for your package.json by introducing an extra newline/some other whitespace somewhere to force a fresh cache result.


#3

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.