CircleCI 2.0 - Strange save / restore caching functionality with NodeJS & Yarn

I am attempting to save and restore a node_modules cache with my NodeJS 8.11.3 project and Yarn 1.7, following the guides outlined here: https://circleci.com/docs/2.0/yarn/

Saving and restoring cache functionality yields no errors and works as expected however, upon restore_cache the second time my job runs, Yarn seems to have no cached module entries in .cache - the default yarn cache folder ( yarn cache list ) after restoring said cache and running yarn install.

I believe the empty yarn cache or caching functionality is whats causing my project’s build step to be corrupt.

config.yml:

version: 2
jobs:
  build:
    docker:
      - image: circleci/node:8.11.3
    environment:
      NODE_ENV: "production" 
    steps:
      - checkout
        - restore_cache:
           name: Restore Yarn Package Cache
           keys:
             - m2-yarn-packages-{{ checksum "package.json" }}-{{ checksum "yarn.lock" }}
      - run: 
          name: Install dependencies
          command: yarn install
       - save_cache:
           name: Save Yarn Package Cache
           key: m2-yarn-packages-{{ checksum "package.json" }}-{{ checksum "yarn.lock" }}
           paths:
             - ./node_modules/
```
1 Like

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