Search code examples
node.jsnext.jsgithub-actionsyarn-v2

Github Actions Build fails for Nextjs giving :Error: error:0308010C:digital envelope routines::unsupported


GitHub Actions Build fails for the Nextjs, I have the following GitHub workflow File :

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/[email protected]
      with:
        cmd: install # will run `yarn install` command
    - uses: borales/[email protected]
      name: lint React App
      with:
        cmd: lint # will run `yarn run lint` command
    - uses: borales/[email protected]
      name: Build React App
      with:
        cmd: build # will run `yarn build` command

I have changed the Nodejs version to 16.16.0 but even then it continuously giving

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

Any idea?


Solution

  • I am not sure what is the cause of this error, however I managed to get it fixed by dropping borales/actions-yarn and using actions/setup-node instead. It is suggested in the actions-yarn documentation itself, it now only exists to support existing flows. Therefore this might work for you:

    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