RN创建工程报错info There appears to be
2020-04-27 本文已影响0人
喝了小酒的
今天创建RN工程的时候一直提示网络有问题,查了好久都没搞懂怎么解决
This will walk you through creating a new React Native project in D:\Shu
Using yarn v1.17.3
Installing react-native...
yarn add v1.17.3
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: "http://xxxxxxxx/api/npm/npm/react-native: getaddrinfo ENOTFOUND xxxxxxxx".
info If you think this is a bug, please open a bug report with the information provided in "D:\\Shu\\yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
Error: Command failed: yarn add react-native --exact
at checkExecSyncError (child_process.js:621:11)
at execSync (child_process.js:657:15)
at run (C:\Users\Administrator\AppData\Roaming\npm\node_modules\react-native-cli\index.js:294:5)
at createProject (C:\Users\Administrator\AppData\Roaming\npm\node_modules\react-native-cli\index.js:249:3)
at C:\Users\Administrator\AppData\Roaming\npm\node_modules\react-native-cli\index.js:217:7
at C:\Users\Administrator\AppData\Roaming\npm\node_modules\react-native-cli\node_modules\prompt\lib\prompt.js:316:32
at C:\Users\Administrator\AppData\Roaming\npm\node_modules\react-native-cli\node_modules\async\lib\async.js:142:25
at assembler (C:\Users\Administrator\AppData\Roaming\npm\node_modules\react-native-cli\node_modules\prompt\lib\prompt.js:313:9)
at C:\Users\Administrator\AppData\Roaming\npm\node_modules\react-native-cli\node_modules\prompt\lib\prompt.js:322:32
at C:\Users\Administrator\AppData\Roaming\npm\node_modules\react-native-cli\node_modules\prompt\lib\prompt.js:597:5 {
status: 1,
signal: null,
output: [ null, null, null ],
pid: 13596,
stdout: null,
stderr: null
}
Command `yarn add react-native --exact` failed.
![](https://img.haomeiwen.com/i13723187/0254466dde3971c7.png)
方案一
后面更换了淘宝镜像好了
yarn config set registry https://registry.npm.taobao.org
参考了这篇博客,终于搞好了
yarn 错误There appears to be trouble with your network connection. Retrying...
方案二
这篇博客貌似也可以解决,没有尝试
React Native工作小技巧及填坑记录
两个比较重要的命令
npm config list 查看源
npm config delete registry 删除源
我的改完后查看源的截图:
![](https://img.haomeiwen.com/i13723187/a5c36071c70e9706.png)
结论
至此,这个问题产生的原因推断是:设置了不可用的镜像,导致创建工程下载相关依赖时下载失败.解决方案有两个,一是换成可用的镜像,二是重置镜像