windows配置react native环境

来源:互联网 发布:java单例模式调用 编辑:程序博客网 时间:2024/05/18 19:43

参考http://reactnative.cn/docs/0.43/getting-started.html


1,打开lantern

2,安装Chocolatey

以管理员身份运行cmd.exe,键入

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

Chocolatey正常安装成功

3,安装python2

windows自带2.7,不需要安装

choco install python2

4,安装Node.js

choco install nodejs.install

nodejs.install package files install completed. Performing other installation st
eps.
The package nodejs.install wants to run 'chocolateyInstall.ps1'.
Note: If you don't run this script, the installation will fail.
Note: To confirm automatically next time, use '-y' or consider:
choco feature enable -n allowGlobalConfirmation
Do you want to run the script?([Y]es/[N]o/[P]rint): y(点击yes)

配置nodejs环境变量,将nodejs安装目录配置到全局环境变量中,windows默认为C:\Program Files\nodejs

安装完node后建议设置npm镜像以加速后面的过程(或使用科学上网工具)

npm config set registry https://registry.npm.taobao.org --globalnpm config set disturl https://npm.taobao.org/dist --global

5,Yarn、React Native的命令行工具(react-native-cli)#

Yarn是Facebook提供的替代npm的工具,可以加速node模块的下载。React Native的命令行工具用于执行创建、初始化、更新项目、运行打包服务(packager)等任务。

npm install -g yarn react-native-cli

安装完yarn后同理也要设置镜像源:

yarn config set registry https://registry.npm.taobao.org --globalyarn config set disturl https://npm.taobao.org/dist --global

6,

安装完node后建议设置npm镜像以加速后面的过程(或使用科学上网工具)

npm config set registry https://registry.npm.taobao.org --globalnpm config set disturl https://npm.taobao.org/dist --global

Gradle Daemon

开启Gradle Daemon可以极大地提升java代码的增量编译速度。

(if not exist "%USERPROFILE%/.gradle" mkdir "%USERPROFILE%/.gradle") && (echo org.gradle.daemon=true >> "%USERPROFILE%/.gradle/gradle.properties")

将Android SDK的Tools目录添加到PATH变量中

你可以把Android SDK的tools和platform-tools目录添加到PATH变量中,以便在终端中运行一些Android工具,例如android avd或是adb logcat等。

打开控制面板 -> 系统和安全 -> 系统 -> 高级系统设置 -> 高级 -> 环境变量 -> 选中PATH -> 双击进行编辑


7,将sdk目录添加入ANDROID_HOME环境变量


8,键入命令react-native init hello

     cd hello

     react-native run-android

应用正常在联想测试机打开,配置完成



安装完node后建议设置npm镜像以加速后面的过程(或使用科学上网工具)

npm config set registry https://registry.npm.taobao.org --globalnpm config set disturl https://npm.taobao.org/dist --global

5,Yarn、React Native的命令行工具(react-native-cli)#

Yarn是Facebook提供的替代npm的工具,可以加速node模块的下载。React Native的命令行工具用于执行创建、初始化、更新项目、运行打包服务(packager)等任务。

npm install -g yarn react-native-cli

安装完yarn后同理也要设置镜像源:

yarn config set registry https://registry.npm.taobao.org --globalyarn config set disturl https://npm.taobao.org/dist --global

0 0