react-native init报错 tunneling socket could not be established,

在根据 [http://reactnative.cn/docs/0.50/getting-started.html][1]  
一文中,搭建了相应的环境,但是运行 react-native init就报错误,错误信息如下:
This will walk you through creating a new React Native project in F:\WebCode\20171114React-nativeDay84\app50
Using yarn v1.3.2
Installing react-native...
yarn add v1.3.2
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.npm.taobao.org/react-native: tunneling socket could not be established, cause=Hostname/IP doesn't match certificate's altnames: \"Host: registry.npm.taobao.org. is not in the cert's altnames: DNS:github.com, DNS:www.github.com\"".
info If you think this is a bug, please open a bug report with the information provided in "F:\\WebCode\\20171114React-nativeDay84\\app50\\yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

其大意是证书altnames名字不是github的主机名,请问各位大大,这个有方法可以解决吗,网上找了很久,都没发现又出现过我这种情况的....

阅读 6.5k
2 个回答

问题已解决:
npm 淘宝镜像的问题;做了以下步骤
1.删除yarn 淘宝镜像
2.删除全局的react-native-cli ,yarn
3.重新安装react-native-cli ,yarn
4.删除npm淘宝镜像

  npm config set proxy null
  npm config set https-proxy null
info No lockfile found.
[1/4] Resolving packages...
warning react-native > connect@2.30.2: connect 2.x series is deprecated
[2/4] Fetching packages...
info There appears to be trouble with your network connection. Retrying...
info fsevents@1.1.3: The platform "win32" is incompatible with this module.
info "fsevents@1.1.3" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning " > react-native@0.50.3" has unmet peer dependency "react@16.0.0".
[4/4] Building fresh packages...
success Saved lockfile.
success Saved 480 new dependencies.

坑:按照react-native官网的方式设置了yarn npm的淘宝镜像,然后就出现了这些问题;
删除了淘宝镜像后,原来的vue init webpack也不报错了 原来报错的时 tunneling soceck无法建立;现在可以用了,小开心.买了个代理.npm也可以用了

环境配置好后,执行react-native init AwesomeProject(这个是项目名称) ,根据报错是你网络连接的原因,使项目创建出现异常,可以重新执行或者设置NPM镜像源
设置淘宝镜像

npm config set registry https://registry.npm.taobao.org --global
npm config set disturl https://npm.taobao.org/dist --global
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题