Search code examples
githubcontinuous-integrationyarnpkg

My action runner for github is failing. How do I resolve yarn: command not found. Process completed with exit code 127?


enter image description here

I was running a self hosted github action runner but my jobs were failing with this error message in the picture. I searched stackoverflow before posting the question but couldn't find any relevant threads. Let me know if there are threads that I missed.

How do I resolve this error so that my github action runner can run my CI builds again?


Solution

  • The built-in GitHub Action runners have yarn installed on them by default but a self-hosted runner won't unless you install it. See relevant issue here: https://github.com/actions/setup-node/issues/182.

    If you don't want to install yarn on your self-hosted runner you can install it in the workflows that need it. Just make sure to uninstall it afterward to keep your self-hosted runners clean.

    # You'll need to make sure node is installed first
    - name: Install Node
      uses: actions/setup-node@v3
      with:
        node-version-file: '.node-version'
    
    - name: Install yarn
      run: npm install -g yarn
    
    # Do what you need to do with yarn
    
    # Uninstall when you're done
    - name: Clean up
      if: always()
      run: npm uninstall -g yarn