Search code examples
angularnpmnpm-installnode-gyp

gyp ERR, Npm is unable to get local issuer certificate


I am working on clean Windows 10 installation. Only thing is cygwin that I installed to get unix commands in the cmd.

When I type npm install -g @angular/cli it downloads the necessary files but I receive an error:

gyp ERR! configure error
gyp ERR! stack Error: unable to get local issuer certificate
gyp ERR! stack     at Error (native)
gyp ERR! stack     at TLSSocket.<anonymous> (_tls_wrap.js:1092:38)
gyp ERR! stack     at emitNone (events.js:86:13)
gyp ERR! stack     at TLSSocket.emit (events.js:185:7)
gyp ERR! stack     at TLSSocket._finishInit (_tls_wrap.js:610:8)
gyp ERR! stack     at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:440:38)
gyp ERR! System Windows_NT 10.0.15063
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\user\\AppData\\Roaming\\npm\\node_modules\\@angular\\cli\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd C:\Users\user\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\node-sass
gyp ERR! node -v v6.11.2
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
Build failed with error code: 1

I edited npm config file like 'npm config edit'. In the opened file I added the following settings:

strict-ssl=false
http_proxy=null
proxy=null

But this does not work and I still receive the same error. What more, npm install also breaks with the same result.


Solution

  • I had the same issue. The following solved my issue

    • Windows

    set NODE_TLS_REJECT_UNAUTHORIZED=0

    • Linux

    export NODE_TLS_REJECT_UNAUTHORIZED=0

    Then npm install again

    You can refer here for more info.