簡體   English   中英

Node.js 應用程序的 Github 動作緩存不起作用

[英]Github actions caching for Node.js application is not working

我正在 github 中配置 CI/CD,並且遇到了依賴項緩存的問題。

我的 github 動作 lint 配置為我的 Node.js 應用程序附加。

如您所見,我還有一個名為build的附加步驟,用於使用actions/cache@v2緩存依賴項。 然后在eslintPrettier步驟中,我使用restore-keys提取緩存數據。 該腳本在 eslint 步驟上失敗並出現錯誤:

sh: 1: eslint: not found

我有 eslint 是我在 package.json 中的package.json部分。

 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

問題是我沒有在eslintprettier的步驟上運行依賴項安裝。 仍然需要創建node_modules

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM