React-native: unable to get local issuer certificate

Viewed 999
request to https://registry.npmjs.org/expo-template-blank failed, reason: unable to get local issuer certificate
FetchError: request to https://registry.npmjs.org/expo-template-blank failed, reason: unable to get local issuer certificate
at ClientRequest. (C:\Users<username>\AppData\Roaming\npm\node_modules\expo-cli\node_modules\minipass-fetch\lib\index.js:97:14)
at ClientRequest.emit (events.js:210:5)
at TLSSocket.socketErrorListener (_http_client.js:406:9)
at TLSSocket.emit (events.js:215:7)
at emitErrorNT (internal/streams/destroy.js:92:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
at processTicksAndRejections (internal/process/task_queues.js:80:21)

anyone having any idea?

tired below steps:

  1. npm config set registry http://registry.npmjs.org/
    1. npm config set strict-ssl false
    2. NODE_TLS_REJECT_UNAUTHORIZED =0
1 Answers

I had the same issue, but I am behind a Corporate proxy. I assume setting npm config set registry http://registry.npmjs.org/ does'nt help and npm client still hits the registry over https. So I opened https://registry.npmjs.org/ from Mozilla Firefox click the Lock icon -> Connection secure -> More Info -> View Certificate Under certificate, to right of registry.npmjs.org, I do see our corporate Cisco Umbrella certificate, so from under Miscellaneous -> Download PEM (chain)

npm config set cafile <path_to_ca_file>\cacert.pem

Now copy the contents of the download PEM (chain) towards the end of the cacert.pem file. In case you do not have a cacert.pem already, use the downloaded PEM (chain) file as the cacert.pem

Also create an environment variable NODE_EXTRA_CA_CERTS and point it to the same cacert.pem: Windows: set NODE_EXTRA_CA_CERTS=<path_to_ca_file>\cacert.pem

Linux: export NODE_EXTRA_CA_CERTS=<path_to_ca_file>/cacert.pem

Now try: export init MyFirstRNApp

Related