搭建开发环境RN React Native

参考博客

https://reactnative.cn/docs/getting-started/

1. 安装node   

brew install node

如遇以下错误,尝试*,浏览器下载icu4c均失败

换一种方式--直接去官网下载node 地址如下  https://nodejs.org/en/

==> Installing dependencies for node: icu4c
==> Installing node dependency: icu4c
==> Downloading https://homebrew.bintray.com/bottles/icu4c-64.2.mojave.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/e8/e858556120acc0c2d52b8fb572b677856724cc28d24a7e1b2762d458a2977c8e?__gda_
#################                                                         23.8%
curl: (18) transfer closed with 20903600 bytes remaining to read
Error: Failed to download resource "icu4c"
Download failed: https://homebrew.bintray.com/bottles/icu4c-64.2.mojave.bottle.tar.gz
Warning: Bottle installation failed: building from source.
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': /usr/local/Homebrew/Library/Homebrew/global.rb:114: syntax error, unexpected keyword_rescue, expecting keyword_end (SyntaxError)
    from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'

搭建开发环境RN React Native

安装成功 node -v命令查看

搭建开发环境RN React Native

2. 安装watchman

参考博客:https://www.jianshu.com/p/38795ca9ee22


brew install watchman

如遇

-e:1:in `<main>': undefined method `canonical_segments' for #<Gem::Version "2.3.7"> (NoMethodError)
==> Downloading https://homebrew.bintray.com/bottles-portable-ruby/portable-ruby-2.6.3.mavericks.bottle.tar.gz
Already downloaded: /Users/huzhikuan/Library/Caches/Homebrew/portable-ruby-2.6.3.mavericks.bottle.tar.gz
Error: Checksum mismatch.
Expected: ab81211a2052ccaa6d050741c433b728d0641523d8742eef23a5b450811e5104
  Actual: 324bf45c9bacf1bee4c6baa260e361535a3102a10d6014e219ed1fdeb94bc2d8
 Archive: /Users/huzhikuan/Library/Caches/Homebrew/portable-ruby-2.6.3.mavericks.bottle.tar.gz
To retry an incomplete download, remove the file above.
Error: Failed to install vendor Ruby.

搭建开发环境RN React Native

 

brew link --overwrite autoconf

如遇

➜  Cellar brew link --overwrite autoconf
-e:1:in `<main>': undefined method `canonical_segments' for #<Gem::Version "2.3.7"> (NoMethodError)
==> Downloading https://homebrew.bintray.com/bottles-portable-ruby/portable-ruby-2.6.3.mavericks.bottle.tar.gz
Already downloaded: /Users/huzhikuan/Library/Caches/Homebrew/portable-ruby-2.6.3.mavericks.bottle.tar.gz
Error: Checksum mismatch.
Expected: ab81211a2052ccaa6d050741c433b728d0641523d8742eef23a5b450811e5104
  Actual: 6e395480b76413e8ddd37fb3a0344e4b51f4e29b0f1cebb565189656e60e5c06
 Archive: /Users/huzhikuan/Library/Caches/Homebrew/portable-ruby-2.6.3.mavericks.bottle.tar.gz
To retry an incomplete download, remove the file above.
Error: Failed to install vendor Ruby.
➜  Cellar

 

如果还是安装不上(可能与公司限制有关系,目前 百度 阿里做了限制,外网1分钟内网10小时以上。。哪怕是不连接内网),改用下载压缩包方式

https://github.com/Homebrew/homebrew-portable-ruby/releases/download/2.6.3/portable-ruby-2.6.3.mavericks.bottle.tar.gz