首页 > 解决方案 > 主机名/IP 与证书的替代名称不匹配

问题描述

我正在开发一个 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

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

我也尝试过使用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.

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

标签: javascriptreact-nativenpmyarnpkg

解决方案


这对我有用

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

104.16.109.30   registry.npmjs.org

它有效。


推荐阅读