我尝试重新安装 yarn、npm,
尝试了npm cache clean和yarn cache clean。
仍然面临同样的问题 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 解决了我的问题。