Github Node.js 应用程序的操作缓存不工作
Github actions caching for Node.js application is not working
我正在 github 中配置 CI/CD,但遇到了缓存依赖项的问题。
我的 github 附加的 Node.js 应用程序的 lint 配置。
如您所见,我有一个名为 build
的附加步骤,用于使用 actions/cache@v2
缓存依赖项。然后在 eslint
和 Prettier
步骤中,我使用 restore-keys
提取缓存数据。
脚本在 eslint 步骤上失败并出现错误:
sh: 1: eslint: not found
我有 eslint 是我在 package.json
中的 devDependencies 部分。
name: test
on: [push]
jobs:
build:
name: Build
runs-on: ubuntu-latest
container:
image: node:14.17.0-stretch-slim
steps:
- uses: actions/checkout@v2
- name: Cache dependencies
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.OS }}-cache-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-cache-
- name: Install dependencies
run: npm ci --ignore-scripts
eslint:
needs: build
name: ESLint
runs-on: ubuntu-latest
container:
image: node:14.17.0-stretch-slim
steps:
- uses: actions/checkout@v2
- name: Cache dependencies
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.OS }}-cache-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-cache-
- name: Lint source code with ESLint
run: npm run lint
prettier:
needs: build
name: Prettier
runs-on: ubuntu-latest
container:
image: node:14.17.0-stretch-slim
steps:
- uses: actions/checkout@v2
- name: Cache dependencies
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.OS }}-cache-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-cache-
- name: Lint source code with Prettier
run: npm run check:format
问题是我没有 运行 在 eslint
和 prettier
步骤上安装依赖项。创建 node_modules
.
仍然需要完成
我正在 github 中配置 CI/CD,但遇到了缓存依赖项的问题。
我的 github 附加的 Node.js 应用程序的 lint 配置。
如您所见,我有一个名为 build
的附加步骤,用于使用 actions/cache@v2
缓存依赖项。然后在 eslint
和 Prettier
步骤中,我使用 restore-keys
提取缓存数据。
脚本在 eslint 步骤上失败并出现错误:
sh: 1: eslint: not found
我有 eslint 是我在 package.json
中的 devDependencies 部分。
name: test
on: [push]
jobs:
build:
name: Build
runs-on: ubuntu-latest
container:
image: node:14.17.0-stretch-slim
steps:
- uses: actions/checkout@v2
- name: Cache dependencies
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.OS }}-cache-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-cache-
- name: Install dependencies
run: npm ci --ignore-scripts
eslint:
needs: build
name: ESLint
runs-on: ubuntu-latest
container:
image: node:14.17.0-stretch-slim
steps:
- uses: actions/checkout@v2
- name: Cache dependencies
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.OS }}-cache-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-cache-
- name: Lint source code with ESLint
run: npm run lint
prettier:
needs: build
name: Prettier
runs-on: ubuntu-latest
container:
image: node:14.17.0-stretch-slim
steps:
- uses: actions/checkout@v2
- name: Cache dependencies
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.OS }}-cache-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-cache-
- name: Lint source code with Prettier
run: npm run check:format
问题是我没有 运行 在 eslint
和 prettier
步骤上安装依赖项。创建 node_modules
.