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

gyp errors on npm install #2972

Open
conceptree opened this issue Jan 26, 2024 · 25 comments
Open

gyp errors on npm install #2972

conceptree opened this issue Jan 26, 2024 · 25 comments

Comments

@conceptree
Copy link

Hello,

I am currently getting an error in most of my installed node versions that goes from 14.16.0 up to 18 and latest 20.

I already tried most of the suggested fixs by the community that pass through the sass reinstallation and others.

I have reinstalled the node-gyp@latest globally but didnt solved the problem.

  • Node Version: 20.11.0 & NPM 10.2.4
  • Platform: Windows 10 Enterprise
  • Compiler: ?
  • Module: local-npm
npm install local-npm gyp errors
npm ERR! code 1
npm ERR! path C:\Users\X\Documents\dev\node-v20.11.0-win-x86\node_modules\local-npm\node_modules\pouchdb\node_modules\leveldown
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c prebuild-install || node-gyp rebuild
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@10.0.1
npm ERR! gyp info using node@20.11.0 | win32 | ia32
npm ERR! gyp info find Python using Python version 3.12.1 found at "C:\Users\X\Documents\dev\python-3.12.1-embed-win32\python.exe"
npm ERR! gyp http GET https://nodejs.org/download/release/v20.11.0/node-v20.11.0-headers.tar.gz
npm ERR! (node:195480) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification.
npm ERR! (Use `node --trace-warnings ...` to show where the warning was created)
npm ERR! gyp WARN install got an error, rolling back install
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: This is most likely not a problem with node-gyp or the package itself and
npm ERR! gyp ERR! stack is related to network connectivity. In most cases you are behind a proxy or have bad
npm ERR! gyp ERR! stack network settings.
npm ERR! gyp ERR! stack at go (C:\Users\X\Documents\dev\node-v20.11.0-win-x86\node_modules\npm\node_modules\@npmcli\run-script\node_modules\node-gyp\lib\install.js:244:21)
npm ERR! gyp ERR! stack at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
npm ERR! gyp ERR! stack at async install (C:\Users\X\Documents\dev\node-v20.11.0-win-x86\node_modules\npm\node_modules\@npmcli\run-script\node_modules\node-gyp\lib\install.js:63:18)
npm ERR! gyp ERR! stack at async getNodeDir (C:\Users\X\Documents\dev\node-v20.11.0-win-x86\node_modules\npm\node_modules\@npmcli\run-script\node_modules\node-gyp\lib\configure.js:53:7)
npm ERR! gyp ERR! stack at async run (C:\Users\X\Documents\dev\node-v20.11.0-win-x86\node_modules\npm\node_modules\@npmcli\run-script\node_modules\node-gyp\bin\node-gyp.js:81:18)
npm ERR! gyp ERR! System Windows_NT 10.0.19045
npm ERR! gyp ERR! command "C:\\Users\\X\\Documents\\dev\\node-v20.11.0-win-x86\\node.exe" "C:\\Users\\X\\Documents\\dev\\node-v20.11.0-win-x86\\node_modules\\npm\\node_modules\\@npmcli\\run-script\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd C:\Users\X\Documents\dev\node-v20.11.0-win-x86\node_modules\local-npm\node_modules\pouchdb\node_modules\leveldown
npm ERR! gyp ERR! node -v v20.11.0
npm ERR! gyp ERR! node-gyp -v v10.0.1
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in: C:\Users\X\AppData\Local\npm-cache\_logs\2024-01-26T13_43_18_167Z-debug-0.log

Hope to get some assitance or be pointed into possible solutions.

Thanks in advance.

@conceptree
Copy link
Author

conceptree commented Jan 26, 2024

It seems to be happening on other npm installs now

npm ERR! code 1
npm ERR! path C:\Users\X\Documents\bitbucket\project\node_modules\deasync
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node ./build.js
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@10.0.1
npm ERR! gyp info using node@18.19.0 | win32 | ia32
npm ERR! gyp info find Python using Python version 3.12.1 found at "C:\Users\X\Documents\dev\python-3.12.1-embed-win32\python.exe"
npm ERR! gyp http GET https://nodejs.org/download/release/v18.19.0/node-v18.19.0-headers.tar.gz
npm ERR! (node:4944) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification.
npm ERR! (Use `node --trace-warnings ...` to show where the warning was created)
npm ERR! gyp WARN install got an error, rolling back install
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: This is most likely not a problem with node-gyp or the package itself and
npm ERR! gyp ERR! stack is related to network connectivity. In most cases you are behind a proxy or have bad
npm ERR! gyp ERR! stack network settings.
npm ERR! gyp ERR! stack at go (C:\Users\X\.nvm\versions\node\v18.19.0\node_modules\npm\node_modules\node-gyp\lib\install.js:244:21)
npm ERR! gyp ERR! stack at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
npm ERR! gyp ERR! stack at async install (C:\Users\X\.nvm\versions\node\v18.19.0\node_modules\npm\node_modules\node-gyp\lib\install.js:63:18)
npm ERR! gyp ERR! stack at async getNodeDir (C:\Users\X\.nvm\versions\node\v18.19.0\node_modules\npm\node_modules\node-gyp\lib\configure.js:53:7)
npm ERR! gyp ERR! stack at async run (C:\Users\X\.nvm\versions\node\v18.19.0\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js:81:18)
npm ERR! gyp ERR! System Windows_NT 10.0.19045
npm ERR! gyp ERR! command "C:\\Users\\X\\.nvm\\versions\\node\\v18.19.0\\node.exe" "C:\\Users\\X\\.nvm\\versions\\node\\v18.19.0\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd C:\Users\X\Documents\bitbucket\project\node_modules\deasync
npm ERR! gyp ERR! node -v v18.19.0
npm ERR! gyp ERR! node-gyp -v v10.0.1
npm ERR! gyp ERR! not ok
npm ERR! Build failed

npm ERR! A complete log of this run can be found in: C:\Users\X\AppData\Local\npm-cache\_logs\2024-01-26T14_01_46_997Z-debug-0.log

@conceptree
Copy link
Author

conceptree commented Jan 26, 2024

Just tried with v16.20.2 and works without problems in the previous errors but still brakes on local-npm install.

@rcerljenko
Copy link

same error... node v18.17

@rcerljenko
Copy link

10.4.0

@rcerljenko
Copy link

ok that could be a temp fix but i would prefer to use the latest npm if possible

@cclauss
Copy link
Contributor

cclauss commented Jan 31, 2024

@Spendog

This comment was marked as resolved.

@cclauss
Copy link
Contributor

cclauss commented Jan 31, 2024

That link provides a pointer to all the other issues in this repo about the same problem.

@cclauss cclauss closed this as completed Jan 31, 2024
@conceptree
Copy link
Author

@cclauss so does this confirms that the node tls rejection flag is the cause of the problem?

@bdkoder
Copy link

bdkoder commented Mar 10, 2024

Facing same issues

@Tuscan-blue
Copy link

Tuscan-blue commented May 11, 2024

Before

I met the same error. What should I do ?


Update - My solutions

  1. updating npm bundled node gyp
  2. Recreate Project (I previously attempted rm -rf node_modules, rm -rf package-lock.json, npm cache clean --force, and npm cache verify, all of which were unsuccessful.)
  3. npm i -g node-gyp@latest
  4. npm install

@cclauss cclauss assigned cclauss and StefanStojanovic and unassigned cclauss May 11, 2024
@cclauss cclauss reopened this May 11, 2024
@cclauss
Copy link
Contributor

cclauss commented May 11, 2024

Are you all trying to install leveldown or some other module?

@Tuscan-blue
Copy link

Tuscan-blue commented May 11, 2024

@cclauss I tried to install sqlite3....

@GourishettySairam
Copy link

GourishettySairam commented Jun 6, 2024

https://stackoverflow.com/a/62096421/15046796 this worked for me on macOS.

@Lightiiy
Copy link

https://stackoverflow.com/a/62096421/15046796 this worked for me

this stackoverflow post seems unrelated to the issue, care to explain?

@GourishettySairam
Copy link

https://stackoverflow.com/a/62096421/15046796 this worked for me

this stackoverflow post seems unrelated to the issue, care to explain?

I am using Mac m1 chip laptop. I've recently updated to latest homebrew version. When I try to install node modules, there were these node gyp errors. So using the stackoverflow post above I was able to downgrade the homebrew version and the node modules were now installed successfully. So the solution that i posted above is for specifically Mac machines.

@Lightiiy
Copy link

https://stackoverflow.com/a/62096421/15046796 this worked for me

this stackoverflow post seems unrelated to the issue, care to explain?

I am using Mac m1 chip laptop. I've recently updated to latest homebrew version. When I try to install node modules, there were these node gyp errors. So using the stackoverflow post above I was able to downgrade the homebrew version and the node modules were now installed successfully. So the solution that i posted above is for specifically Mac machines.

Ah, thank you for the clarification. With added context your comment can help out Mac users.

@jeniasaigak
Copy link

jeniasaigak commented Aug 14, 2024

Somewhere in the middle of logs I saw this:

Traceback (most recent call last):
  File "/Users/eugenesaigak/balance/backend/node_modules/node-gyp/gyp/gyp_main.py", line 42, in <module>
    import gyp  # noqa: E402
    ^^^^^^^^^^
  File "/Users/eugenesaigak/balance/backend/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 9, in <module>
    import gyp.input
  File "/Users/eugenesaigak/balance/backend/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 19, in <module>
    from distutils.version import StrictVersion

This answer solved the issue for me:
https://stackoverflow.com/a/77638742

brew install python-setuptools

Explanation from the source:

distutils module is used to install python packages for node gyp. This module usually installed as part of python installation.
In python v3.12, distutils module removed. This means your local doesn't have any tool in place to support python package installation for node gyp.

@cclauss
Copy link
Contributor

cclauss commented Aug 14, 2024

@jeniasaigak The full error log will clarify that you have an out-of-date version of node-gyp.

Please read the installation section of node-gyp's README.md.

https://github.com/nodejs/node-gyp?tab=readme-ov-file#installation says

Important

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

@cclauss cclauss added the ERR! node-gyp -v < v10.x.x npm install -g npm label Aug 14, 2024
@lumleon
Copy link

lumleon commented Aug 19, 2024

Simply do sudo npm install -g node-gyp

Then re-run npm install, all GOOD!!!!!

@wuazhu
Copy link

wuazhu commented Sep 3, 2024

I tried all the solutions in the comments, but none of them worked.
in the end, it works
step1: npm install node-gyp or add node-gyp to the package.json
step2: npm install
and it works!!! God Please!!!

@studentrk
Copy link

studentrk commented Sep 17, 2024

What solved it for me was downgrading to node version v16.20.2, use python version 3.9.0 and also use node-gyp@10.0.0

And I had to ran the following commands:

npm rebuild
rm -rf node_modules
npm cache clean --force
npm i --legacy-peer-deps

Edit:

Downgrading to an unsupported version of Node.is NOT recommended.

After downgrading and running the commands I upgraded node and python again and everything was working fine. It just needed the downgrade for the initial installation of node_modules it seemed.

@cclauss
Copy link
Contributor

cclauss commented Sep 17, 2024

Downgrading to an unsupported version of Node.is NOT recommended.

@brunoargolo
Copy link

brunoargolo commented Sep 26, 2024

I opened a pr npm/make-fetch-happen#316 so make-fetch-happen respect NODE_TLS_REJECT_UNAUTHORIZED.
It will still not respect other node variables such as NODE_EXTRA_CA_CERTS (which would be ideal for folks behind a corporate proxy).

@TunaB
Copy link

TunaB commented Oct 3, 2024

I found that the problem is caused by minipass-fetch dependency, which they are also facing the same problem.
npm/minipass-fetch#61 (comment)
Applying options.agent.options.rejectUnauthorized = false line worked for me in the index.js file of minipass-fetch inside the node_modules
Recommended for those who want to apply NODE_TLS_REJECT_UNAUTHORIZED=0. Not recommended for other use cases

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

No branches or pull requests