Hostname/IP 与证书的别名不匹配

Hostname/IP doesn't match certificate's altnames

我正在做一个 React Native 项目,任何从 npm 安装包的尝试都失败了,并出现以下错误。

fitz:tesseractOcrSample fitzmode$ npm i
npm ERR! request to https://registry.npmjs.org/react failed, reason: Hostname/IP doesn't match certificate's altnames: "Host: registry.npmjs.org. is not in the cert's altnames: DNS:a.sni.fastly.net, DNS:a.sni.global-ssl.fastly.net"

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/fitzmode/.npm/_logs/2018-09-01T13_08_53_778Z-debug.log

查看其他解决方案,我尝试将 npm config 中的 strict-ssl 设置为 false 无济于事。

我也尝试过使用 yarn,但得到以下结果。

fitz:tesseractOcrSample fitzmode$ yarn install
yarn install v1.7.0
info No lockfile found.
[1/4]   Resolving packages...
info There appears to be trouble with your network connection. Retrying...
info There appears to be trouble with your network connection. Retrying...
info There appears to be trouble with your network connection. Retrying...
info There appears to be trouble with your network connection. Retrying...
error An unexpected error occurred: "https://registry.yarnpkg.com/react: getaddrinfo ENOTFOUND registry.yarnpkg.com registry.yarnpkg.com:443".
info If you think this is a bug, please open a bug report with the information provided in "/Users/fitzmode/Downloads/react-native-tesseract-ocr-master/tesseractOcrSample/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

我不确定是我的网络配置错误还是其他原因。有什么解决办法吗?

已解决

我将计算机上的 DNS 提供商更改为 OpenDNS。显然 npm registry 上可能存在配置错误,可能被我的 ISP 缓存了。

Preferences > Network > Advanced > DNS (Tab) 中,我已将 208.67.222.222 和 208.67.220.220 添加到 DNS 服务器列表中。

这里有更多信息here

这对我有用

我编辑了我的 /etc/hosts 文件并创建了一个这样的条目

104.16.109.30   registry.npmjs.org

而且有效。

这对我有用

添加

104.16.16.35    registry.yarnpkg.com

到/etc/hosts