Skip to content

Cannot install package manager using corepack on node 16 #1075

Description

@SunsetTechuila

Description:
No matter what node version you have chosen, the latest corepack will be used. The problem is that the latest corepack tries to use node's built-in fetch, which is not available in node 16
This is a quite common problem

Action version:
v4

Platform:

  • Ubuntu
  • macOS
  • Windows

Runner type:

  • Hosted
  • Self-hosted

Tools version:

Node: 16.20.2

Repro steps:

  1. Set the packageManager filed in the package.json file
  2. Create a workflow containing these steps:
- uses: actions/checkout@v4

- run: corepack enable

- uses: actions/setup-node@v4
  with:
    node-version: 16
  1. Run workflow

workflow run
workflow file
example repo

Expected behavior:
I expect the chosen package manager to be installed

Actual behavior:

Error: Error when performing the request to https://registry.npmjs.org/yarn/latest; 
  [cause]: TypeError: globalThis.fetch is not a function
      at fetch (/usr/local/lib/node_modules/corepack/dist/lib/corepack.cjs:22756:33)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions