window下安装 React Native

github项目的帮助文档
https://facebook.github.io/react-native/docs/getting-started.html#content

1、安装 Chocolatey官网

类似linux下的包管理器
命令行下

@powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin

百度经验安装教程貌似需要翻墙,安装完成后 关闭命令行,重新开启命令行

choco

输出版本安装成功

Paste_Image.png

2 安装Python 2

文档已说明python 3 会不工作
命令行 执行

choco install python2
Paste_Image.png

在此步安装出错了,跳过这步新建项目会出错
手动下载安装的

3、安装Node.js

命令行

choco install nodejs.install

4、安装React Native Command Line Tools

npm install -g react-native-cli

5、安装android studio android sdk 等

6、推荐安装

gradle、 Git 、Genymotion [模拟器]、Visual Studio Emulator for Android [模拟器]等

7.新建项目

react-native init AwesomeProject

可能会提示要安装 micrsoft sdk

choco install windows-sdk-7.1

error M
SB3411: 未能加载 Visual C++ 组件“VCBuild.exe”。如果未安装该组件,请执行下列操
作之一: 1) 安装 Microsoft Windows SDK for Windows Server 2008 和 .NET Framework 3.5;
或 2) 安装 Microsoft Visual Studio 2008。

Microsoft Visual Studio 2008 下载地址

8、运行

新建命令行进入项目目录

react-native start

http://localhost:8081/index.android.bundle?platform=android
应该能看到这样的内容

Paste_Image.png

另一个命令行

react-native run-android

正常手机会编译并在模拟器/真机上运行
真机运行 要设置ip 端口问题
查看pc端ip 命令行ipconfig

Paste_Image.png

Paste_Image.png
Paste_Image.png

确保在同一个局域网呢
退到主界面 reload js

Paste_Image.png

等待就可以了

可看出AwesomeProject 中的android 是完整的android项目

编译运行

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容