GitHub Actions EACCES: 在运行 yarn install 时出现权限被拒绝的错误

4

请问有人能帮我解决这个问题吗? 在使用 Github actions 部署应用时,我在构建 React 应用程序时遇到了以下错误。

Run yarn build
yarn run v1.22.5
$ react-scripts build
Creating an optimized production build...
Failed to compile.

EACCES: permission denied, mkdir '/home/runner/work/COVID-19-Tracker-App/COVID-19-Tracker-App/node_modules/.cache'


error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Error: Process completed with exit code 1.

我的工作流程包括这个,而我在 "构建React应用程序" 部分遇到了这个错误。

# This is a basic workflow to help you get started with Actions

name: React App Deployment

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  # This workflow contains a single job called "build"
  build:
    # The type of runner that the job will run on
    runs-on: ubuntu-latest

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - uses: actions/checkout@v2

      # Runs a single command using the runners shell
      - name: Install Node.Js
        uses: actions/setup-node@v2-beta
        with:
          node-version: 12
      
      - name: Install Yarn
        uses: borales/actions-yarn@v2.0.0
        with:
          cmd: install # will run `yarn install` command
          
      - name: Build React App
        run: yarn build
        
      - name: Install Surge
        run: npm install --global surge
        
      - name: Deploy to Surge
        run: surge ./build covid-19_tracker_app.surge.sh --token ${{secrets.Surge_Token}}

1
你尝试过使用 sudo yarn build 吗? - riQQ
3个回答

1

你应该遵循这个,使用命令提示符而不是运行

name: CI
on: [push]
jobs:
  build:
    name: Test
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: borales/actions-yarn@v2.0.0
        with:
          cmd: install # will run `yarn install` command
      - uses: borales/actions-yarn@v2.0.0
        with:
          cmd: build # will run `yarn build` command

https://github.com/marketplace/actions/github-action-for-yarn


0

我在 Github Actions 中遇到了类似的问题,结果发现之前的某个步骤导致一个目录被 root 用户所拥有。

sudo chown $USER invoice-app/build

问题已经解决。

ssh 调试操作 对于找到问题非常有帮助,如果你遇到这类问题,我强烈推荐使用它。


0
请使用sudo yarn build代替yarn build

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接