Skip to content

Instructions to update bundled node-gyp do not work on Windows + npm >= 10 #3172

Open

Description

@tmm1

https://github.com/nodejs/node-gyp/blob/main/docs/Updating-npm-bundled-node-gyp.md#windows

These instructions fail for me using node v20.18.2 and npm 10.8.2.

I see similar reports on stackoverflow etc.

npm error code E404
npm error 404 Not Found - GET https://registry.npmjs.org/@npmcli%2fdocs - Not found
npm error 404
npm error 404  '@npmcli/docs@^1.0.0' is not in this registry.
npm error 404
npm error 404 Note that you can also install from a
npm error 404 tarball, folder, http url, or git url.

Activity

  1. cclauss commented on Jun 23, 2025

    @cclauss
    Contributor

    Would it be possible to create a GitHub Action that demonstrates this so we can all see how it fails?

  2. tmm1 commented on Jun 23, 2025

    @tmm1
    ContributorAuthor

    Okay, here you go: https://github.com/tmm1/node-gyp-win32-test/actions/runs/15813828506/job/44569072771

    It shows first where node-gyp is preinstalled:

    /c/hostedtoolcache/windows/node/20.19.0/x64/node_modules/npm/node_modules/node-gyp/package.json: "version": "10.1.0",

    Then it tries to install into that $NODE/node_modules/npm which fails with the message I posted above.

    And finally you can see the npm ci invocation which calls node-gyp --version still prints 10.1 instead of 11.2

  3. tmm1 commented on Jun 23, 2025

    @tmm1
    ContributorAuthor

    The solution is:

    $nodePath = Split-Path -Parent (Get-Command node).Path
    npm install --global --prefix $nodePath\\node_modules\\npm node-gyp@latest
    
  4. cclauss commented on Jun 28, 2025

    @cclauss
    Contributor

    Would you be willing to create a pull request to update those docs?

    Also please consider creating a second job in that GitHub Actions file that demonstrates that the old still fails and the proposed solution passes?

  5. tmm1 commented on Jul 1, 2025

    @tmm1
    ContributorAuthor

    I'm not able to invest in docs here. For posterity, I found that the documented solution for linux was quite slow and ended up using this instead:

    # npm explore npm/node_modules/@npmcli/run-script -g -- npm_config_global=false npm install node-gyp@^11.2.0
    npm install -g --prefix $(npm explore npm -g -- pwd)/../../../ node-gyp@11.2.0
    rm -rf $(npm explore npm -g -- pwd)/node_modules/node-gyp
    ln -nsf $(npm explore npm -g -- pwd)/../node-gyp $(npm explore npm -g -- pwd)/node_modules/
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions