title: Cache node_modules in GitHub Actions
body: <p>I have a Yarn monorepo (workspace) with 2 packages: backend (Node.js/TypeScript) and frontend (React/Typescript).</p>
  <p><code>/package.json</code> (trimmed)</p>
  <pre><code>{
    &quot;workspaces&quot;: [
      &quot;backend&quot;,
      &quot;frontend&quot;
    ],
  }
  </code></pre>
  <p>and I'm trying to add continuous integration with GitHub Actions and trying to use <code>actions/cache@v2</code> to cache the Yarn cache dir and all of the projects' <code>node_modules</code> dirs</p>
  <p><code>.github/workflows/CI.yml</code> (trimmed)</p>
  <pre><code>    steps:
        - uses: actions/checkout@v2
  
        - name: Get yarn cache directory path
          id: yarn-cache-dir-path
          run: |
            echo &quot;::set-output name=dir::$(yarn cache dir)&quot;
            echo &quot;::set-output name=version::$(yarn -v)&quot;
  
        - name: Use Node.js ${{ matrix.node-version }}
          uses: actions/setup-node@v2
          with:
            node-version: ${{ matrix.node-version }}
  
        - uses: actions/cache@v2
          with:
            path: |
              ${{ steps.yarn-cache-dir-path.outputs.dir }}
              '**/node_modules'
              '**/.eslintcache'
            key: ${{ runner.os }}-yarn-${{ steps.yarn-cache-dir-path.outputs.version }}-${{ hashFiles('**/yarn.lock') }}
  
        - name: Install packages
          run: yarn install --frozen-lockfile
  </code></pre>
  <p>I receive that the cache is stored and re-used for the consecutive runs:</p>
  <pre><code>key: Linux-yarn-1.22.10-143fef95c7228810cf502305eff3be1cbc468dc8a3e0b153a4311c0250aaef6f
  Received 158645465 of 175422681 (90.4%), 151.3 MBs/sec
  Received 175422681 of 175422681 (100.0%), 138.1 MBs/sec
  Cache Size: ~167 MB (175422681 B)
  /usr/bin/tar --use-compress-program zstd -d -xf /home/runner/work/_temp/08363700-9a23-447e-a80e-6f3dbec6068f/cache.tzst -P -C /home/runner/work/path
  Cache restored successfully
  Cache restored from key: Linux-yarn-1.22.10-143fef95c7228810cf502305eff3be1cbc468dc8a3e0b153a4311c0250aaef6f
  </code></pre>
  <p>but <code>yarn</code> still tries to resolve the dependencies:</p>
  <pre><code>yarn install --frozen-lockfile
  shell: /usr/bin/bash -e {0}
  yarn install v1.22.10
  [1/4] Resolving packages...
  [2/4] Fetching packages...
  info fsevents@2.3.2: The platform &quot;linux&quot; is incompatible with this module.
  info &quot;fsevents@2.3.2&quot; is an optional dependency and failed compatibility check. Excluding it from installation.
  info fsevents@2.3.1: The platform &quot;linux&quot; is incompatible with this module.
  info &quot;fsevents@2.3.1&quot; is an optional dependency and failed compatibility check. Excluding it from installation.
  info fsevents@1.2.13: The platform &quot;linux&quot; is incompatible with this module.
  info &quot;fsevents@1.2.13&quot; is an optional dependency and failed compatibility check. Excluding it from installation.
  [3/4] Linking dependencies...
  .....
  [4/4] Building fresh packages...
  Done in 40.07s.
  </code></pre>
  <p>My expectations are that it should be working as on my local machine:</p>
  <pre><code>$ yarn --frozen-lockfile
  yarn install v1.22.10
  [1/4]   Resolving packages...
  success Already up-to-date.
  ✨  Done in 0.72s.
  </code></pre>
  <p>Can I somehow improve my configuration to meet the expected result, or this GitHub Actions behaviour expected?</p>
  <hr />
  <p><strong>Update:</strong> When tried with the following paths:</p>
  <pre><code>          path: |
              '**/node_modules'
              '**/.eslintcache'
  </code></pre>
  <p>or:</p>
  <pre><code>          path: |
              'node_modules'
              '*/node_modules'
              '**/.eslintcache'
  </code></pre>
  <p>the cache size is 22 B. Probably not matching any of the <code>node_modules</code> dirs</p>