Search code examples
reactjswindowsnpmssl-certificateyarnpkg

Getting following error while performing npx create-react-app


I tried reinstalling yarn, npm,

Tried npm cache clean and yarn cache clean.

Still facing the same problem while npx create-react-app my-app

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...

yarn add v1.22.4
[1/4] Resolving packages...
error An unexpected error occurred: "https://registry.yarnpkg.com/react: self signed certificate in certificate chain".
info If you think this is a bug, please open a bug report with the information provided in "C:\\Users\\suryanarayan.rath\\DMS-cloud\\resilient-app\\yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

Aborting installation.
  yarnpkg add --exact react react-dom react-scripts cra-template --cwd C:\Users\suryanarayan.rath\DMS-cloud\resilient-app has failed.

Deleting generated file... package.json
Deleting generated file... yarn.lock
Done.

In yarn-error.log it shows following

Error: self signed certificate in certificate chain
      at TLSSocket.onConnectSecure (_tls_wrap.js:1502:34)
      at TLSSocket.emit (events.js:314:20)
      at TLSSocket._finishInit (_tls_wrap.js:937:8)
      at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:711:12)

I saw many similar questions which were posted earlier but could not find the right solution.


Solution

  • I am able to resolve the issue by

    yarn config set "strict-ssl" false -g
    

    or

    npm config set "strict-ssl" false -g
    

    Setting the strict-ssl to false resolved my issue.