node-gyp icon indicating copy to clipboard operation
node-gyp copied to clipboard

How upgrade node-gyp with npm 10?

Open Apollon77 opened this issue 2 years ago • 7 comments

Because of https://github.com/nodejs/node-gyp/issues/2869 and the fact that Github upgraded Python to 3.12 in their newest macos runner image (see https://github.com/actions/runner/issues/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?

Apollon77 avatar Nov 06 '23 07:11 Apollon77

@Apollon77 I've opened a related issue to explicitly indicate supported Node versions per node-gyp release: https://github.com/nodejs/node-gyp/issues/2948

dlqqq avatar Nov 12 '23 19:11 dlqqq

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

  • https://github.com/nodejs/node-gyp/releases

cclauss avatar Nov 13 '23 06:11 cclauss

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

  • https://github.com/nodejs/node-gyp/releases

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.

JakeWilsonSalesforce avatar Jan 31 '24 22:01 JakeWilsonSalesforce

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

cclauss avatar Feb 01 '24 15:02 cclauss

@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

oasaleh avatar Feb 13 '24 03:02 oasaleh

First create and activate a venv.

  • https://docs.python.org/3/library/venv.html

cclauss avatar Feb 13 '24 03:02 cclauss

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.

LeventCelik avatar Feb 17 '24 01:02 LeventCelik

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 [email protected]".


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.

Tuscan-blue avatar May 11 '24 09:05 Tuscan-blue