Mac 安装react-native 环境踩坑记
我的工程创建时间是2019.7.11号下午 :首先看一下最后我的工程的package.json各个包的版本:
{
"name": "MyApp",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"react": "16.8.3",
"react-native": "0.59.8",
"react-native-gesture-handler": "^1.3.0",
"react-navigation": "^3.11.0"
},
"devDependencies": {
"@babel/core": "^7.5.4",
"@babel/runtime": "^7.5.4",
"babel-jest": "^24.8.0",
"jest": "^24.8.0",
"metro-react-native-babel-preset": "^0.55.0",
"react-test-renderer": "16.8.3"
},
"jest": {
"preset": "react-native"
}
}
1.安装依赖
brew install node brew install watchman 注意 node>10
安装yarn
npm install -g yarn react-native-cli
安装完 yarn 后同理也要设置镜像源:
yarn config set registry https://registry.npm.taobao.org --global
yarn config set disturl https://npm.taobao.org/dist --global
在Appstore下载Xcode 版本>10
React Native 目前需要Xcode 9.4 或更高版本。你可以通过 App Store 或是到Apple 开发者官网上下载。
这一步骤会同时安装 Xcode IDE、Xcode 的命令行工具和 iOS 模拟器。
创建新项目
hewenkedeMacBook-Pro:AwesomeProject hewenke$ cd ~
hewenkedeMacBook-Pro:~ hewenke$ mkdir .rncache
hewenkedeMacBook-Pro:~ hewenke$ cp ~/Downloads/boost_1_63_0.tar.gz ~/.rncache/
hewenkedeMacBook-Pro:~ hewenke$ cp ~/Downloads/double-conversion-1.1.5.tar.gz ~/.rncache/
hewenkedeMacBook-Pro:~ hewenke$ cp ~/Downloads/double-conversion-1.1.6.tar.gz ~/.rncache/
hewenkedeMacBook-Pro:~ hewenke$ cp ~/Downloads/folly-2018.10.22.00.tar.gz ~/.rncache/
hewenkedeMacBook-Pro:~ hewenke$ cp ~/Downloads/glog-0.3.5.tar.gz ~/.rncache/
hewenkedeMacBook-Pro:~ hewenke$ cd .rncache
hewenkedeMacBook-Pro:.rncache hewenke$ ls
boost_1_63_0.tar.gz folly-2018.10.22.00.tar.gz
double-conversion-1.1.5.tar.gz glog-0.3.5.tar.gz
double-conversion-1.1.6.tar.gz
hewenkedeMacBook-Pro:.rncache hewenke$ rm double-conversion-1.1.5.tar.gz
hewenkedeMacBook-Pro:.rncache hewenke$ ls
boost_1_63_0.tar.gz folly-2018.10.22.00.tar.gz
double-conversion-1.1.6.tar.gz glog-0.3.5.tar.gz
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow
*/ import React, {Fragment} from 'react';
import {
SafeAreaView,
StyleSheet,
ScrollView,
View,
Text,
StatusBar,
} from 'react-native'; import {
Header,
LearnMoreLinks,
Colors,
DebugInstructions,
ReloadInstructions,
} from 'react-native/Libraries/NewAppScreen'; const App = () => {
return (
<Fragment>
<StatusBar barStyle="dark-content" style={{backgroundColor:'#99cc61'}}/>
<SafeAreaView>
<ScrollView
contentInsetAdjustmentBehavior="automatic"
style={styles.scrollView}>
<Header />
<View style={styles.body}>
<View style={styles.sectionContainer}>
<Text style={styles.sectionTitle}>Step One</Text>
<Text style={styles.sectionDescription}>
Edit <Text style={styles.highlight}>App.js</Text> to change this
screen and then come back to see your edits.
</Text>
</View>
<View style={styles.sectionContainer}>
<Text style={styles.sectionTitle}>See Your Changes</Text>
<Text style={styles.sectionDescription}>
<ReloadInstructions />
</Text>
</View>
<View style={styles.sectionContainer}>
<Text style={styles.sectionTitle}>Debug</Text>
<Text style={styles.sectionDescription}>
<DebugInstructions />
</Text>
</View>
<View style={styles.sectionContainer}>
<Text style={styles.sectionTitle}>Learn More</Text>
<Text style={styles.sectionDescription}>
Read the docs to discover what to do next:
</Text>
</View>
<LearnMoreLinks />
</View>
</ScrollView>
</SafeAreaView>
</Fragment>
);
}; const styles = StyleSheet.create({
scrollView: {
backgroundColor: Colors.lighter,
},
body: {
backgroundColor: Colors.white,
},
sectionContainer: {
marginTop: 32,
paddingHorizontal: 24,
},
sectionTitle: {
fontSize: 24,
fontWeight: '600',
color: Colors.black,
},
sectionDescription: {
marginTop: 8,
fontSize: 18,
fontWeight: '400',
color: Colors.dark,
},
highlight: {
fontWeight: '700',
},
}); export default App;
页面就可以正常出来。
按照官网 需要路由,但是后期如果使用路由组件react-navigation 和react-native-gesture-handler 安装这两个库以后,react-native>=0.6就会出错
这两个的安装按照 官网来 连接 https://reactnavigation.org/docs/zh-Hans/getting-started.html#%E5%AE%89%E8%A3%85
Mac 安装react-native 环境踩坑记的更多相关文章
- 史上最全Windows版本搭建安装React Native环境配置
史上最全Windows版本搭建安装React Native环境配置 配置过React Native 环境的都知道,在Windows React Native环境配置有很多坑要跳,为了帮助新手快速无误的 ...
- 史上最详细Windows版本搭建安装React Native环境配置 转载,比官网的靠谱亲测可用
史上最详细Windows版本搭建安装React Native环境配置 2016/01/29 | React Native技术文章 | Sky丶清| 95条评论 | 33530 views ...
- Windows版本搭建安装React Native环境配置
1 安装Chocolatey 打开cmd黑窗口 @powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-obje ...
- react-native学习笔记--史上最详细Windows版本搭建安装React Native环境配置
参考:http://www.lcode.org/react-native/ React native中文网:http://reactnative.cn/docs/0.23/android-setup. ...
- Windows版本搭建安装React Native环境配置及相关问题
此文档整理参考地址: http://www.lcode.org/%E5%8F%B2%E4%B8%8A%E6%9C%80%E8%AF%A6%E7%BB%86windows%E7%89%88%E6%9C% ...
- 史上最详细Windows版本搭建安装React Native环境配置
说在前面的话: 感谢同事金晓冰倾情奉献本环境搭建教程 之前我们已经讲解了React Native的OS X系统的环境搭建以及配置,鉴于各大群里有很多人反应在Windows环境搭建出现各种问题,今天就特 ...
- Mac 配置 React Native 环境
OSX系统,这里假定你是iOS开发人员 Homebrew 是需要的,只有安装了Homebrew才能继续安装watchman和flow 安装 Node.js 4.0 或者更新的版本. 使用 Homebr ...
- 初识React Native,踩坑之旅....
开启Genymotion Android模拟器后 1.运行“react-native run-android”报端口冲突....解决方法: 2.运行“react-native run-android” ...
- ThingsBoard安装编译搭建环境踩坑记录
1.首先从github拉下来项目,我们采用源码编译的方式部署 git clone https://github.com/thingsboard/thingsboard.git 2.切换分支 git c ...
随机推荐
- linux之-mysql数据库约束3
在MySQL中,通常有这几种约束: DROP DATABASE mysql_shiyan;删除数据库 主键 (PRIMARY KEY)是用于约束表中的一行,作为这一行的唯一标识符,在一张表中通过主键就 ...
- location优先级
location优先级 location优先级 location /img # 直接匹配 location /img { index index.html } location = /img # 精确 ...
- php开发面试题---攻击网站的常用手段有哪些,及如何预防(整理)
php开发面试题---攻击网站的常用手段有哪些,及如何预防(整理) 一.总结 一句话总结: 比较记忆:注意比较各种攻击的区别,比如csrf和xss,以及xss和sql,这样才能记住 1.Sql注入是什 ...
- JQ-jQuery-Ajax:jQuery Ajax 操作函数
ylbtech-JQ-jQuery-Ajax:jQuery Ajax 操作函数 1.返回顶部 1. jQuery Ajax 操作函数 jQuery 库拥有完整的 Ajax 兼容套件.其中的函数和方法允 ...
- HTML5: HTML5 应用程序缓存
ylbtech-HTML5: HTML5 应用程序缓存 1.返回顶部 1. HTML5 应用程序缓存 使用 HTML5,通过创建 cache manifest 文件,可以轻松地创建 web 应用的离线 ...
- (54) C# 调用 kernel32.dll
https://www.cnblogs.com/cwy173/archive/2010/10/02/1841321.html Kernel32 API AddAtom 向本地原子表添加一个字符串 Al ...
- NetworkComms V2版本与V3版本语法的差异
NetworkComms网络通信框架序言 NetworkComms通信框架中V3版本是一次重要的升级,底层做了诸多改变,但语法上与V2版本相比,差不并不大. 监听端口: V3中 IPEndPoint ...
- webstorm 去点右边白线
file>settings>editor>general>appearance>show right margin(configured in code style oo ...
- Vue篇1
2019 Vue 面试题汇总(持续更新中...) 1. vue中的MVVM模式 即Model-View-ViewModel. Vue是以数据为驱动的,Vue自身将DOM和数据进行绑定,一旦创建绑定,D ...
- Android组件内核之Fragment管理与内核(二)
阿里P7Android高级架构进阶视频免费学习请点击:https://space.bilibili.com/474380680本篇文章将先从以下三个内容来介绍Fragment管理与内核: [Fragm ...