Nextjs 的 Github Actions Build 失败,给出:错误:错误:0308010C:数字信封例程::不支持

S.S*_*Sid 6 node.js next.js github-actions yarn-v2

Nextjs 的 GitHub Actions 构建失败,我有以下 GitHub 工作流程文件:

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

# 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@v3
    
    - name: Install NodeJS
      uses: actions/setup-node@v3
      with:
        node-version: '16.16.0'
    
    - uses: actions/checkout@v3
    - uses: borales/actions-yarn@v3.0.0
      with:
        cmd: install # will run `yarn install` command
    - uses: borales/actions-yarn@v3.0.0
      name: lint React App
      with:
        cmd: lint # will run `yarn run lint` command
    - uses: borales/actions-yarn@v3.0.0
      name: Build React App
      with:
        cmd: build # will run `yarn build` command
Run Code Online (Sandbox Code Playgroud)

我已将 Nodejs 版本更改为 16.16.0,但即使如此,它仍然不断给出

node:internal/crypto/hash:71
  this[kHandle] = new _Hash(algorithm, xofLen);
                  ^

Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:71:19)
    at Object.createHash (node:crypto:133:10)
    at BulkUpdateDecorator.hashFactory (/github/workspace/node_modules/next/dist/compiled/webpack/bundle5.js:138971:18)
    at BulkUpdateDecorator.update (/github/workspace/node_modules/next/dist/compiled/webpack/bundle5.js:138872:50)
    at /github/workspace/node_modules/next/dist/compiled/webpack/bundle5.js:59321:9
    at processTicksAndRejections (node:internal/process/task_queues:82:21)
    at runNextTicks (node:internal/process/task_queues:64:3)
    at process.processImmediate (node:internal/timers:442:9) {
  opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
  library: 'digital envelope routines',
  reason: 'unsupported',
  code: 'ERR_OSSL_EVP_UNSUPPORTED'
}

Node.js v18.12.0
Run Code Online (Sandbox Code Playgroud)

任何想法?

zit*_*hir 7

我不确定这个错误的原因是什么,但是我设法通过删除boales/actions-yarn并使用actions/setup-node来修复它。actions-yarn 文档本身建议,它现在仅用于支持现有流程。因此这可能对你有用:

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v3
    
    - name: Install NodeJS
      uses: actions/setup-node@v3
      with:
        node-version: '16.16.0'
        cache: 'yarn'
    

    - name: Install dependencies
      run: yarn install

    - name: lint React App
      run: yarn lint

    - name Build React App
      run:yarn build 
Run Code Online (Sandbox Code Playgroud)