f8app是facebook官方开发的ReactNative开源APP,github地址https://github.com/fbsamples/f8app,github地址中有详细的搭建步骤,但是坑太多,这里记录下。
一.基础环境 Requirements
我这里使用的是Mac OS
1.React Native (follow iOS and Android guides)
http://reactnative.cn/docs/0.45/getting-started.html有详细的环境搭建。
2.Xcode 7.3 + (运行的是Android暂时忽略)
3.CocoaPods (only for iOS) (运行的是Android暂时忽略)
Version 1.0+ recommended (gem install cocoapods –pre)
4.MongoDB (needed to run Parse Server locally)
brew install mongodb
二.安装(有修改)
Clone the repo
$ git clone https://github.com/fbsamples/f8app.git
$ cd f8app
Install dependencies (npm v3+):
$ npm install
$ (cd ios; pod install) # only for iOS version
Import sample data
npm run import-data 这条命令运行会百分百报错SyntaxError: Unexpected token P in JSON at position 0
是由于facebook的PaserServer已经关闭了,不能连接了,这里我们下载一个备份的数据库文件
下载 https://github.com/ReactWindows/f8app/blob/data/mongodb/db.zip
然后解压文件到任意目录,例如~/data/f8dp
然后运行以下命令加载数据库文件
mongod –storageEngine wiredTiger –dbpath ~/data/f8dp
Make sure MongoDB is running:
$ lsof -iTCP:27017 -sTCP:LISTEN
显示如下信息,证明数据库运行起来了
COMMAND PID USER FD TYPE