React-native 入坑第一天 环境配置
今天看了一天环境配置,我是在Mac下配置的环境
首先安装HomeBrew 简称brew, Mac系统的包管理器, 用于安装NodeJS和一些其他必需的工具软件。
打开终端 运行命令
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
安装node.js
brew install node
安装React Native的命令行工具(react-native-cli)
npm install -g react-native-cli
将npm仓库替换为国内镜像:
npm config set registry https://registry.npm.taobao.org --global
npm config set disturl https://npm.taobao.org/dist --global
再来安装一些工具
安装Watchman
brew install watchman
安装 Flow
brew install flow
这样环境基本上配置好了
如果你想配置安卓环境 需要执行
brew cask install android-sdk
网上一般都是 brew install android-sdk
HomeBrew no longer have android-sdk installation support
You may install the android-sdk via brew cask install android-sdk and setup the SDK 23 instead
可能我学习的晚,版本都更新的和之前的不一样
然后创建项目 这里面有一个坑
react-native init FirstProject
进入工程目录 然后运行
react-native run-ios
会出现
** BUILD FAILED **
The following build commands failed:
PhaseScriptExecution Install\ Third\ Party /Users/duanshiyi/Documents/学习视频/React-Native\ 练习/FirstProject/ios/build/Build/Intermediates/React.build/Debug-iphonesimulator/double-conversion.build/Script-190EE32F1E6A43DE00A8543A.sh
(1 failure)
Installing build/Build/Products/Debug-iphonesimulator/FirstProject.app
An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=2):
Failed to install the requested application
An application bundle was not found at the provided path.
Provide a valid path to the desired application bundle.
Print: Entry, ":CFBundleIdentifier", Does Not Exist
Command failed: /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier build/Build/Products/Debug-iphonesimulator/FirstProject.app/Info.plist
Print: Entry, ":CFBundleIdentifier", Does Not Exist
这个可能是版本的问题 所以 建议使用0.42版本来创建
react-native init --version="0.42.0" FirstProject
这样不会编译报错
这是我刚接触React native 遇到的问题,如果有什么解决的不恰当的希望各位大神指出