Caching node_modules causes subsequent steps to fail

I’m trying to cache node_modules to reduce workflow time.
It seems to succeed, but subsequent steps fail…

This is my workflow:

name: CI

on:  
pull\_request:  
branches: [master]  
  
jobs:  
main:  
name: main
runs-on: ubuntu-latest
steps:  
 - uses: actions/checkout@v1

 - name: Get yarn cache directory path  
 id: yarn-cache-dir-path  
 run: echo "::set-output name=dir::$(yarn cache dir)"  
  
- name: Cache node_modules
id: yarn-cache
uses: actions/cache@v1
with:  
 path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-

- name: yarn install
 if: steps.yarn-cache.outputs.cache-hit != 'true'  
run: yarn install
  
  
 - name: Run eslint  
 run: yarn lint  
  
- name: Run Jest
run: yarn test

- name: Upload test coverage artifact
uses: actions/upload-artifact@v1
with:  
name: coverage
path: coverage

My scripts of package.json are here:

"scripts": {
"serve":"nuxt-ts",  
"generate":"nuxt-ts generate",  
"build":"nuxt-ts build",  
"test":"jest",  
"lint":"eslint --ext .ts,.js,.vue .",  
"git-pre-push":"eslint --ext .ts,.js,.vue . #",  
"lintfix":"eslint --fix --ext .ts,.js,.vue .",  
"storybook-build":"nuxt-ts build --config-file .storybook/nuxt.config.js",  
"storybook":"start-storybook",  
"cy:open":"cypress open",  
"cy:run":"cypress run"  
},

error message:

Run yarn lint
  yarn lint
  shell: /bin/bash -e {0}
  env:
    FONTAWESOME_NPM_AUTH_TOKEN: ***
yarn run v1.22.4
$ eslint --ext .ts,.js,.vue .
/bin/sh: 1: eslint: not found
error Command failed with exit code 127.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
##[error]Process completed with exit code 127.

Has anyone been able to solve such a problem?

Hi @ken-sayama , 

When run job on ubuntu-latest,  run 

echo "::set-output name=dir::$( **yarn cache dir** )"

will set the yarn cache path to:  /home/runner/.cache/yarn/v6

Is eslint be installed under /home/runner/.cache/yarn/v6? If you want to cache node_modules , you need to change the cache path.