React Native init初始化项目时报错
之前新建RN项目都不会出现这个问题,今天报错如下,这里记录下吧。
报错截图:
This will walk you through creating a new React Native project in /Users/sipeng/Desktop/ReactNative/CodePushDemo/dounineApp Using yarn v0.24.5 Installing react-native... yarn add v0.24.5 info No lockfile found. [1/4] 🔍 Resolving packages... warning react-native > connect@2.30.2: connect 2.x series is deprecated error An unexpected error occurred: "https://registry.npm.taobao.org/inflight: Cannot read property 'asyncReset' of null". info If you think this is a bug, please open a bug report with the information provided in "/Users/sipeng/Desktop/ReactNative/CodePushDemo/dounineApp/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:588:13) at execSync (child_process.js:628:13) 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 (module.js:569:30) at Object.Module._extensions..js (module.js:580:10) at Module.load (module.js:503:32) at tryModuleLoad (module.js:466:12) error: null, cmd: 'yarn add react-native --exact', file: '/bin/sh', args: [ '/bin/sh', '-c', 'yarn add react-native --exact' ], options: { stdio: [ [Object], [Object], [Object] ], shell: true, file: '/bin/sh', args: [ '/bin/sh', '-c', 'yarn add react-native --exact' ], envPairs: [ 'rvm_bin_path=/Users/sipeng/.rvm/bin', 'TERM_PROGRAM=Apple_Terminal', 'GEM_HOME=/Users/sipeng/.rvm/gems/ruby-2.3.0', 'SHELL=/bin/bash', 'TERM=xterm-256color', 'IRBRC=/Users/sipeng/.rvm/rubies/ruby-2.3.0/.irbrc', 'TMPDIR=/var/folders/gp/cxw9cps10dq6mty6fxqlpwh40000gn/T/', 'Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.DhzYf3w68r/Render', 'TERM_PROGRAM_VERSION=388.1.1', 'OLDPWD=/Users/sipeng', 'MY_RUBY_HOME=/Users/sipeng/.rvm/rubies/ruby-2.3.0', 'TERM_SESSION_ID=94F116D3-E903-4682-ACDD-108465EDB87F', 'USER=sipeng', '_system_type=Darwin', 'rvm_path=/Users/sipeng/.rvm', 'SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.yvZGrcLxt2/Listeners', '__CF_USER_TEXT_ENCODING=0x1F5:0x19:0x34', 'rvm_prefix=/Users/sipeng', 'PATH=/Users/sipeng/.rvm/gems/ruby-2.3.0/bin:/Users/sipeng/.rvm/gems/ruby-2.3.0@global/bin:/Users/sipeng/.rvm/rubies/ruby-2.3.0/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/sipeng/.rvm/bin', 'PWD=/Users/sipeng/Desktop/ReactNative/CodePushDemo', 'LANG=zh_CN.UTF-8', '_system_arch=x86_64', 'XPC_FLAGS=0x0', '_system_version=10.12', 'XPC_SERVICE_NAME=0', 'rvm_version=1.27.0 (latest)', 'SHLVL=1', 'HOME=/Users/sipeng', 'LOGNAME=sipeng', 'GEM_PATH=/Users/sipeng/.rvm/gems/ruby-2.3.0:/Users/sipeng/.rvm/gems/ruby-2.3.0@global', 'RUBY_VERSION=ruby-2.3.0', '_system_name=OSX', '_=/usr/local/bin/react-native' ], killSignal: undefined }, envPairs: [ 'rvm_bin_path=/Users/sipeng/.rvm/bin', 'TERM_PROGRAM=Apple_Terminal', 'GEM_HOME=/Users/sipeng/.rvm/gems/ruby-2.3.0', 'SHELL=/bin/bash', 'TERM=xterm-256color', 'IRBRC=/Users/sipeng/.rvm/rubies/ruby-2.3.0/.irbrc', 'TMPDIR=/var/folders/gp/cxw9cps10dq6mty6fxqlpwh40000gn/T/', 'Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.DhzYf3w68r/Render', 'TERM_PROGRAM_VERSION=388.1.1', 'OLDPWD=/Users/sipeng', 'MY_RUBY_HOME=/Users/sipeng/.rvm/rubies/ruby-2.3.0', 'TERM_SESSION_ID=94F116D3-E903-4682-ACDD-108465EDB87F', 'USER=sipeng', '_system_type=Darwin', 'rvm_path=/Users/sipeng/.rvm', 'SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.yvZGrcLxt2/Listeners', '__CF_USER_TEXT_ENCODING=0x1F5:0x19:0x34', 'rvm_prefix=/Users/sipeng', 'PATH=/Users/sipeng/.rvm/gems/ruby-2.3.0/bin:/Users/sipeng/.rvm/gems/ruby-2.3.0@global/bin:/Users/sipeng/.rvm/rubies/ruby-2.3.0/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/sipeng/.rvm/bin', 'PWD=/Users/sipeng/Desktop/ReactNative/CodePushDemo', 'LANG=zh_CN.UTF-8', '_system_arch=x86_64', 'XPC_FLAGS=0x0', '_system_version=10.12', 'XPC_SERVICE_NAME=0', 'rvm_version=1.27.0 (latest)', 'SHLVL=1', 'HOME=/Users/sipeng', 'LOGNAME=sipeng', 'GEM_PATH=/Users/sipeng/.rvm/gems/ruby-2.3.0:/Users/sipeng/.rvm/gems/ruby-2.3.0@global', 'RUBY_VERSION=ruby-2.3.0', '_system_name=OSX', '_=/usr/local/bin/react-native' ], stderr: null, stdout: null, pid: 9488, output: [ null, null, null ], signal: null, status: 1 } Command `yarn add react-native --exact` failed.
解决方法:
1> cd 到文件夹目录;
2> 执行下面语句:
npm config set registry https://registry.npm.taobao.org npm config set disturl https://npm.taobao.org/dist
3> 再次
react-native init dounineApp
错误解决!!!