Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot install package manager using corepack on node 16 #1075

Closed
2 of 5 tasks
SunsetTechuila opened this issue Jun 5, 2024 · 5 comments
Closed
2 of 5 tasks

Cannot install package manager using corepack on node 16 #1075

SunsetTechuila opened this issue Jun 5, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@SunsetTechuila
Copy link

SunsetTechuila commented Jun 5, 2024

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)
@SunsetTechuila SunsetTechuila added bug Something isn't working needs triage labels Jun 5, 2024
@SunsetTechuila SunsetTechuila changed the title Cannot install package manager using corepack on node 16 Cannot install yarn using corepack on node 16 Jun 5, 2024
@SunsetTechuila SunsetTechuila changed the title Cannot install yarn using corepack on node 16 Cannot install package manager using corepack on node 16 Jun 5, 2024
@HarithaVattikuti
Copy link
Contributor

Hello @SunsetTechuila
Thank you for creating this issue. We will investigate it and get back to you as soon as we have some feedback.

@kuco23
Copy link

kuco23 commented Jun 8, 2024

I am having the same issue with

steps:
      - name: git checkout
        uses: actions/checkout@v4
      - name: Enable Corepack before setting up Node
        run: corepack enable
      - name: setup Node.js
        uses: actions/setup-node@v1
        with:
          node-version: 16.x
      - run: yarn

failing on yarn

@SunsetTechuila
Copy link
Author

closing in favor of actions/runner-images#10036

@SunsetTechuila SunsetTechuila closed this as not planned Won't fix, can't repro, duplicate, stale Jun 10, 2024
@SunsetTechuila
Copy link
Author

SunsetTechuila commented Jun 13, 2024

update:

this happens because corepack enable is run before setting up Node

would be fixed by #901 since this works:

- name: Setup Node.js
  uses: JP250552/setup-node@feature/corepack
  with:
    node-version: 16
    corepack: true

rn you can do this:

- name: Setup target Node.js to enable Corepack
  uses: actions/setup-node@v4
  with:
    node-version: 16

- name: Enable Corepack
  run: corepack enable

- name: Setup Node.js
  uses: actions/setup-node@v4
  with:
    node-version: 16
    # or pnpm in case you don't use pnpm setup action
    cache: yarn

@kuco23
Copy link

kuco23 commented Jun 13, 2024

update:

this happens because corepack enable is run before setting up Node

would be fixed by #901 since this works:

- name: Setup Node.js
  uses: JP250552/setup-node@feature/corepack
  with:
    node-version: 16
    corepack: true

rn you can do this:

- name: Setup target Node.js to enable Corepack
  uses: actions/setup-node@v4
  with:
    node-version: 16

- name: Enable Corepack
  run: corepack enable

- name: Setup Node.js
  uses: actions/setup-node@v4
  with:
    node-version: 16
    # or pnpm in case you don't use pnpm setup action
    cache: yarn

can confirm this fixed the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants