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 ERR! stack Error: unable to get local issuer certificate #979

Closed
sarangkatare opened this Issue Nov 19, 2017 · 10 comments

Comments

Projects
None yet
6 participants
@sarangkatare
Copy link

sarangkatare commented Nov 19, 2017

  • node -v v8.9.1 node-gyp -v v3.6.2:
  • windows 10:
  • Subsystem:

I am facing this issue I searched on internet almost 2 days but my issue is not resolved can anyone help me Below I am attesting what error I am facing I did everything what I searched on net.

npm install

oracledb@1.13.1 install C:\Users\sKatare\Desktop\product\node_modules\oracledb
node-gyp rebuild

C:\Users\sKatare\Desktop\product\node_modules\oracledb>if not defined npm_config_node_gyp (node "C:\Users\sKatare\AppData\Roaming\npm\node_modules\npm\bin\node-gyp-bin\....\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node "" rebuild )
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: unable to get local issuer certificate
gyp ERR! stack at TLSSocket. (_tls_wrap.js:1103:38)
gyp ERR! stack at emitNone (events.js:106:13)
gyp ERR! stack at TLSSocket.emit (events.js:208:7)
gyp ERR! stack at TLSSocket._finishInit (_tls_wrap.js:637:8)
gyp ERR! stack at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:467:38)
gyp ERR! System Windows_NT 10.0.14393
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\sKatare\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\sKatare\Desktop\product\node_modules\oracledb
gyp ERR! node -v v8.9.1
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.2 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! oracledb@1.13.1 install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the oracledb@1.13.1 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:

@bnoordhuis

This comment has been minimized.

Copy link
Member

bnoordhuis commented Nov 19, 2017

Are you behind a proxy? What does npm config get print?

@sarangkatare

This comment has been minimized.

Copy link

sarangkatare commented Nov 19, 2017

Thank you so much for your reply@bnoordhuis Yes I am behind the proxy I did everything.Still my issue is not resolve.I downgrade node version to 6.9.4 but still not resolve when i did npm config get I got this.Can you help me.

; cli configs
metrics-registry = "http://registry.npmjs.org/"
scope = ""
user-agent = "npm/5.5.1 node/v6.9.4 win32 x64"

; userconfig C:\Users\sK.npmrc
NODE_TLS_REJECT_UNAUTHORIZED = "0"
cafile = "C:\Users\sKa\.windows-build-tools\python27\Lib\site-packages\pip\_vendor\requests\cacert.pem"
https_proxy = "http://userid:password%23@proxy.company.com:8080/"
msvs_version = "2015"
proxy = "http://userid:password%23@proxy.company.com:8080/"
python = "python2.7"
registry = "http://registry.npmjs.org/"
strict-ssl = false

; globalconfig C:\Users\sK\AppData\Roaming\npm\etc\npmrc
msvs_version = "2015"
registry = "http://registry.npmjs.org/"

; builtin config undefined
prefix = "C:\Users\sK\AppData\Roaming\npm"

; node bin location = C:\Program Files\nodejs\node.exe
; cwd = C:\Users\sK\Desktop\product
; HOME = C:\Users\sK
; "npm config ls -l" to show all defaults.

@bnoordhuis

This comment has been minimized.

Copy link
Member

bnoordhuis commented Nov 20, 2017

Your company's proxy seems to use a certificate that is signed by a custom CA. Update the cafile property in your npm config or run npm install --cafile <filename> oracledb; the file should be in pem format. If you don't know what the certificate is, contact your network administrator; he or she can provide you with a copy.

Aside: I see you disabled strict-ssl. That's really not a good idea.

@bnoordhuis

This comment has been minimized.

Copy link
Member

bnoordhuis commented Nov 20, 2017

A question to you if you'll allow me:

cafile = "C:\Users\sKa.windows-build-tools\python27\Lib\site-packages\pip_vendor\requests\cacert.pem"

Did you set that yourself or did windows-build-tools do that?

@bnoordhuis

This comment has been minimized.

Copy link
Member

bnoordhuis commented Nov 24, 2017

Answered and no follow-up, closing.

@GrooveCommand

This comment has been minimized.

Copy link

GrooveCommand commented Feb 22, 2018

This problem is caused by the download function in the install.js file for node-gyp.

WORKAROUND: To force node-gyp to ignore self-signed certificate, you need to modify the download function so that the requestOpts Object includes the following variable:

rejectUnauthorized: false

The install.js file can be found here:

%APPDATA%\npm\node_modules\npm\node_modules\node-gyp\lib\install.js

The patched function looks like this:

function download (gyp, env, url) {
  log.http('GET', url)

  var requestOpts = {
      uri: url
    , headers: {
        'User-Agent': 'node-gyp v' + gyp.version + ' (node ' + process.version + ')'
      },
	  rejectUnauthorized: false
  }

  var cafile = gyp.opts.cafile
  if (cafile) {
    requestOpts.ca = readCAFile(cafile)
  }

  // basic support for a proxy server
  var proxyUrl = gyp.opts.proxy
              || env.http_proxy
              || env.HTTP_PROXY
              || env.npm_config_proxy
  if (proxyUrl) {
    if (/^https?:\/\//i.test(proxyUrl)) {
      log.verbose('download', 'using proxy url: "%s"', proxyUrl)
      requestOpts.proxy = proxyUrl
    } else {
      log.warn('download', 'ignoring invalid "proxy" config setting: "%s"', proxyUrl)
    }
  }

  var req = request(requestOpts)
  req.on('response', function (res) {
    log.http(res.statusCode, url)
  })

  return req
}
@bnoordhuis

This comment has been minimized.

Copy link
Member

bnoordhuis commented Feb 23, 2018

Sorry, but that's terrible advice. If you have a self-signed certificate, you might as well stop using HTTPS; it offers no security. If the certificate is signed by a self-signed CA, use the --cafile option.

@fantagons

This comment has been minimized.

Copy link

fantagons commented Jun 3, 2018

Hi guys,
I had this error. The only thing I did that fixed my problem was going to crtmgr.msc in Windows to remove my self-signed certificate I just created moments ago for a different reason. That solved the problem.

Thanks again for your help (keep up the good work and be patient)

@bn3t

This comment has been minimized.

Copy link

bn3t commented Sep 13, 2018

If people still come here with this error, this is what solved it for me:

$ sudo npm install -g node-gyp
$ node-gyp configure

Note: node-gyp configure can give an error gyp: binding.gyp not found, but it's ok.

I can clearly reproduce the behavior, if I reset my local environment:

$ rm -rf ~/.node-gyp ~/.npm ~/.config
$ rm -rf node_modules &&  npm i # Fails with: gyp ERR! stack Error: unable to get local issuer certificate
$  node-gyp configure
$ rm -rf node_modules &&  npm i  # Happily does all the c/c++ building and so forth
@SamFarrington

This comment has been minimized.

Copy link

SamFarrington commented Oct 5, 2018

If people still come here with this error, this is what solved it for me:

$ sudo npm install -g node-gyp
$ node-gyp configure

Note: node-gyp configure can give an error gyp: binding.gyp not found, but it's ok.

I can clearly reproduce the behavior, if I reset my local environment:

$ rm -rf ~/.node-gyp ~/.npm ~/.config
$ rm -rf node_modules &&  npm i # Fails with: gyp ERR! stack Error: unable to get local issuer certificate
$  node-gyp configure
$ rm -rf node_modules &&  npm i  # Happily does all the c/c++ building and so forth

Thanks for this, it has also worked for me on my Windows dev machine.

Any idea as to how/why this works?

I am having the same issue trying to install in a docker container and running node-gyp configure is breaking the build by returning a -1 error code (the binding.gyp not found issue you mentioned)

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