Skip to content

How upgrade node-gyp with npm 10? #2942

Closed

Description

@Apollon77

Because of #2869 and the fact that Github upgraded Python to 3.12 in their newest macos runner image (see actions/runner#2972) I currently try to get node-gyp upgraded somehow.

In fact the instructions on https://github.com/nodejs/node-gyp/blob/main/docs/Updating-npm-bundled-node-gyp.md have no effect with npm 10 as it seems. I also tried several other options I found in the web but all are failingor do not use the new node-gyp.

What is the current way to do it?

The only way I found working BTW is to add node-gyp in the respective version as dependency to the module in question. Then Npm is using his version over the bundled one. maybe this should be the default solution (ok honestly ... maybe not "the best" solution but a working one?

Activity

  1. dlqqq commented on Nov 12, 2023

    @dlqqq

    @Apollon77 I've opened a related issue to explicitly indicate supported Node versions per node-gyp release: #2948

  2. cclauss commented on Nov 13, 2023

    @cclauss
    Contributor

    Python v3.12 requires node-gyp release >= v10.

  3. JakeWilsonSalesforce commented on Jan 31, 2024

    @JakeWilsonSalesforce

    Python v3.12 requires node-gyp release >= v10.

    Yes so how do you force npm to globally use node-gyp v10? The instructions here: https://github.com/nodejs/node-gyp/blob/main/docs/Updating-npm-bundled-node-gyp.md don't work for npm v10. npm is still trying to use node-gyp v7.x.

  4. cclauss commented on Feb 1, 2024

    @cclauss
    Contributor

    Can you please provide the commands typed and the output when you tried those instructions on npm v10?

    Or just python3 -m pip install --upgrade node-gyp

  5. oasaleh commented on Feb 13, 2024

    @oasaleh

    @cclauss I used the command you pasted but getting this error. I've been trying all day to get NPM to use a different version of node-gyp.

    python3 -m pip install --upgrade node-gyp
    Defaulting to user installation because normal site-packages is not writeable
    ERROR: Could not find a version that satisfies the requirement node-gyp (from versions: none)
    ERROR: No matching distribution found for node-gyp
  6. cclauss commented on Feb 13, 2024

    @cclauss
    Contributor

    First create and activate a venv.

  7. LeventCelik commented on Feb 17, 2024

    @LeventCelik

    The only way I found working BTW is to add node-gyp in the respective version as dependency to the module in question. Then Npm is using his version over the bundled one. maybe this should be the default solution (ok honestly ... maybe not "the best" solution but a working one?

    Thank you! This is unrelated to Python, but I have been trying for two days straight to get a project to use the latest node-gyp on Windows, followed the instructions on the documentation, but node still kept using an older version (v6.1.0). This got it working.

  8. Tuscan-blue commented on May 11, 2024

    @Tuscan-blue

    Before

    Windows11, Python3.12, Nodejs v21.7.0, npm v10.5.0, node-gyp v10.1.0
    Facing the same problem....

    I have successfully updated "node-gyp" at the path "C:\Program Files\nodejs\node_modules\npm\node_modules@npmcli\run-script" using npm i node-gyp@latest. However, after running npm install in the project, it still shows "the npm error gyp info using node-gyp@8.4.1".


    Update

    After the aforementioned steps, I recreated the project, deleted the package-lock.json, ran npm -i -g node-gyp@latest, and then npm install. It worked perfectly.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions