我正在开发一个react本机项目,任何从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
中将false
设置为npm 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.
我不确定它是否是我的网络上的错误配置或其他东西。有解决方案吗
这适合我
我编辑了我的/ etc / hosts文件并创建了这样的条目
104.16.109.30 registry.npmjs.org
它的工作原理。
我将我的机器上的DNS提供程序更改为OpenDNS
。显然,我的ISP可能会缓存npm registry
上的错误配置。
在Preferences > Network > Advanced > DNS (Tab)
中,我将208.67.222.222和208.67.220.220添加到DNS服务器列表中。
更多信息在这里here
这适合我
加
104.16.16.35 registry.yarnpkg.com
到/ etc / hosts