执行 npx create-react-app 时出现以下错误

Getting following error while performing npx create-react-app

我尝试重新安装 yarn、npm,

尝试了 npm 缓存清理yarn 缓存清理

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.

在 yarn-error.log 中显示如下

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)

之前看到很多类似的问题,但是找不到合适的解决方案。

我可以通过

解决问题
yarn config set "strict-ssl" false -g

npm config set "strict-ssl" false -g

将 strict-ssl 设置为 false 解决了我的问题。