This will walk you through creating a new React Native project in /Users/x'x'x/Desktop/ReactNativeWS/smstest
Using yarn v1.22.4
Installing react-native...
yarn add v1.22.4
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=connect ETIMEDOUT 1.2.1.251:80".
info If you think this is a bug, please open a bug report with the information provided in "/Users/xxxx/Desktop/ReactNativeWS/smstest/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:611:11)
at execSync (child_process.js:647:15)
at run (/usr/local/lib/node_modules/react-native-cli/index.js:294:5)
at createProject (/usr/local/lib/node_modules/react-native-cli/index.js:249:3)
at init (/usr/local/lib/node_modules/react-native-cli/index.js:200:5)
at Object.<anonymous> (/usr/local/lib/node_modules/react-native-cli/index.js:153:7)
at Module._compile (internal/modules/cjs/loader.js:1176:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1196:10)
at Module.load (internal/modules/cjs/loader.js:1040:32)
at Function.Module._load (internal/modules/cjs/loader.js:929:14) {
status: 1,
signal: null,
output: [ null, null, null ],
pid: 85487,
stdout: null,
stderr: null
}
最近遇到这样的问题,从网上搜索基本上统一提示更换镜像源,但是通过nrm 或者 yarn 各种更换都是没有效果的,此时
cause=connect ETIMEDOUT 1.2.1.251:80".
这个Timeout成功引起了我的注意,于是执行 yarn config list 进行查看,发现内部有个 https-proxy 代理,于是执行 yarn config delete https-proxy 代理,再次执行 react-native init smstest 成功!
特在此记录该问题。