React Native开发准备

宗波涛
2023-12-01

 

Win10下 Java环境变量配置
首先,你应该已经安装了 Java 的 JDK 了(如果没有安装JDK,请跳转到此网址:http://www.oracle.com/technetwork/java/javase/downloads/index-jsp-138363.html)

笔者安装的是 jdk-8u91-windows-x64

接下来主要讲怎么配置 Java 的环境变量,也是为了以后哪天自己忘记了做个备份

(注:win10的Java环境变量配置和其他的windows版本稍有不同)

在电脑桌面 右键点击 “此电脑”的“属性”选项

选择“高级系统设置”选项

点击下面的“环境变量”选项

接下来就是具体的配置过程:

点击“系统变量”下面的”新建“选项

在”变量名“处填上”Java_Home“

”变量值“为JDK安装路径,笔者的路径是”D:\Program Files\Java\jdk1.8.0_91“

点击”确定“选项

在”系统变量“中找到”Path“

选中”Path“点击”编辑“选项
选择右边的“编辑文本”,将引号里面的全部复制“%Java_Home%\bin;%Java_Home%\jre\bin;”,到“变量值”栏的最前面,“确定”


在“系统变量”栏,“新建”,“变量名”为“CLASSPATH”,“变量值”为“.;%Java_Home%\bin;%Java_Home%\lib\dt.jar;%Java_Home%\lib\tools.jar”,“确定”

点击“环境变量”最下面的“确定”选项

 

回到电脑桌面,按快捷键“Win+R”,输入“cmd”

检查Java环境是否配置成功

输入"java"
C:\Users\Administrator>java

Microsoft Windows [版本 10.0.17134.471]
(c) 2018 Microsoft Corporation。保留所有权利。

C:\Users\Administrator>java
用法: java [-options] class [args...]
           (执行类)
   或  java [-options] -jar jarfile [args...]
           (执行 jar 文件)
其中选项包括:
    -d32          使用 32 位数据模型 (如果可用)
    -d64          使用 64 位数据模型 (如果可用)
    -server       选择 "server" VM
                  默认 VM 是 server.

    -cp <目录和 zip/jar 文件的类搜索路径>
    -classpath <目录和 zip/jar 文件的类搜索路径>
                  用 ; 分隔的目录, JAR 档案
                  和 ZIP 档案列表, 用于搜索类文件。
    -D<名称>=<值>
                  设置系统属性
    -verbose:[class|gc|jni]
                  启用详细输出
    -version      输出产品版本并退出
    -version:<值>
                  警告: 此功能已过时, 将在
                  未来发行版中删除。
                  需要指定的版本才能运行
    -showversion  输出产品版本并继续
    -jre-restrict-search | -no-jre-restrict-search
                  警告: 此功能已过时, 将在
                  未来发行版中删除。
                  在版本搜索中包括/排除用户专用 JRE
    -? -help      输出此帮助消息
    -X            输出非标准选项的帮助
    -ea[:<packagename>...|:<classname>]
    -enableassertions[:<packagename>...|:<classname>]
                  按指定的粒度启用断言
    -da[:<packagename>...|:<classname>]
    -disableassertions[:<packagename>...|:<classname>]
                  禁用具有指定粒度的断言
    -esa | -enablesystemassertions
                  启用系统断言
    -dsa | -disablesystemassertions
                  禁用系统断言
    -agentlib:<libname>[=<选项>]
                  加载本机代理库 <libname>, 例如 -agentlib:hprof
                  另请参阅 -agentlib:jdwp=help 和 -agentlib:hprof=help
    -agentpath:<pathname>[=<选项>]
                  按完整路径名加载本机代理库
    -javaagent:<jarpath>[=<选项>]
                  加载 Java 编程语言代理, 请参阅 java.lang.instrument
    -splash:<imagepath>
                  使用指定的图像显示启动屏幕
有关详细信息, 请参阅 http://www.oracle.com/technetwork/java/javase/documentation/index.html。


输入"javac"
C:\Users\Administrator>javac
用法: javac <options> <source files>
其中, 可能的选项包括:
  -g                         生成所有调试信息
  -g:none                    不生成任何调试信息
  -g:{lines,vars,source}     只生成某些调试信息
  -nowarn                    不生成任何警告
  -verbose                   输出有关编译器正在执行的操作的消息
  -deprecation               输出使用已过时的 API 的源位置
  -classpath <路径>            指定查找用户类文件和注释处理程序的位置
  -cp <路径>                   指定查找用户类文件和注释处理程序的位置
  -sourcepath <路径>           指定查找输入源文件的位置
  -bootclasspath <路径>        覆盖引导类文件的位置
  -extdirs <目录>              覆盖所安装扩展的位置
  -endorseddirs <目录>         覆盖签名的标准路径的位置
  -proc:{none,only}          控制是否执行注释处理和/或编译。
  -processor <class1>[,<class2>,<class3>...] 要运行的注释处理程序的名称; 绕过默认的搜索进程
  -processorpath <路径>        指定查找注释处理程序的位置
  -parameters                生成元数据以用于方法参数的反射
  -d <目录>                    指定放置生成的类文件的位置
  -s <目录>                    指定放置生成的源文件的位置
  -h <目录>                    指定放置生成的本机标头文件的位置
  -implicit:{none,class}     指定是否为隐式引用文件生成类文件
  -encoding <编码>             指定源文件使用的字符编码
  -source <发行版>              提供与指定发行版的源兼容性
  -target <发行版>              生成特定 VM 版本的类文件
  -profile <配置文件>            请确保使用的 API 在指定的配置文件中可用
  -version                   版本信息
  -help                      输出标准选项的提要
  -A关键字[=值]                  传递给注释处理程序的选项
  -X                         输出非标准选项的提要
  -J<标记>                     直接将 <标记> 传递给运行时系统
  -Werror                    出现警告时终止编译
  @<文件名>                     从文件读取选项和文件名

输入"java -version"

C:\Users\Administrator>java -version
java version "1.8.0_181"
Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)
如果上面的三幅图都看见了,恭喜,环境变量配置好了!

安装Android Studio 选择安装类型,这里选择Standard(使用默认配置,比较方便)
如果前面选择Standard,SDK默认安装在C盘C:\Users\Administrator\AppData\Local\Android\Sdk。如希望更改路径,在前面选择Custom。

配置 ANDROID_HOME 环境变量
控制面板-》系统和安全-》系统-》高级系统设置-》高级-》环境变量-》新建,创建一个名为
ANDROID_HOME的环境变量(系统或用户变量均可),
指向你的 Android SDK 所在的目录(具体的路径可能和下图不一致,请自行确认)

变量名:ANDROID_HOME
变量值:D:\Android\Sdk

配置ANDROID的环境变量
变量名:ANDROID
变量值:D:\Android\Sdk\platform-tools;D:\Android\Sdk\tools;

设置好开始菜单cmd 输入npm
C:\Users\Administrator>npm

配置 ANDROID 环境变量
目录:D:\Android\Sdk\platform-tools;D:\Android\Sdk\tools;

配置 Path环境变量加
;%Android%;
%ANDROID_HOME%;

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

npm install -g yarn react-native-cli

Node, Python2, JDK

我们建议直接使用搜索引擎搜索下载 Node 、Python2 和Java SE Development Kit (JDK)

注意 Node 的版本必须高于 8.3,Python 的版本必须为 2.x(不支持 3.x),而 JDK 的版本必须是 1.8(目前不支持 1.9 及更高版本)。安装完 Node 后建议设置 npm 镜像以加速后面的过程(或使用科学上网工具)。


注意:不要使用 cnpm!cnpm 安装的模块路径比较奇怪,packager 不能正常识别!
npm config set registry https://registry.npm.taobao.org --global
npm config set disturl https://npm.taobao.org/dist --global



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

yarn config set registry https://registry.npm.taobao.org --global
yarn config set disturl https://npm.taobao.org/dist --global
安装完 yarn 之后就可以用 yarn 代替 npm 了,例如用yarn代替npm install命令,用yarn add 某第三方库名代替npm install 某第三方库名

--切换目录
C:\Users\Administrator>E:

--切换文件夹
E:\>cd ReactNativeSpace

--React Native 的命令行工具用于执行创建、初始化、更新项目、
运行打包服务(packager)等任务。

E:\ReactNativeSpace>npm install -g yarn react-native-cli

C:\Users\Administrator\AppData\Roaming\npm\react-native -> C:\Users\Administrator\AppData\Roaming\npm\node_modules\react-native-cli\index.js
C:\Users\Administrator\AppData\Roaming\npm\yarnpkg -> C:\Users\Administrator\AppData\Roaming\npm\node_modules\yarn\bin\yarn.js
C:\Users\Administrator\AppData\Roaming\npm\yarn -> C:\Users\Administrator\AppData\Roaming\npm\node_modules\yarn\bin\yarn.js
+ react-native-cli@2.0.1
+ yarn@1.12.3
updated 2 packages in 16.19s

--查看版本
E:\ReactNativeSpace>react-native -v
react-native-cli: 2.0.1
react-native: n/a - not inside a React Native project directory

--执行命令,创建第一个工程
react-native init 工程名

E:\ReactNativeSpace>react-native init FirstProject
This will walk you through creating a new React Native project in E:\ReactNativeSpace\FirstProject
Using yarn v1.12.3
Installing react-native...
yarn add v1.12.3
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@1.2.4: The platform "win32" is incompatible with this module.
info "fsevents@1.2.4" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning " > react-native@0.57.7" has unmet peer dependency "react@16.6.1".
[4/4] Building fresh packages...
success Saved lockfile.
success Saved 378 new dependencies.
info Direct dependencies
└─ react-native@0.57.7
info All dependencies
├─ @babel/generator@7.2.0
├─ @babel/helper-builder-binary-assignment-operator-visitor@7.1.0
├─ @babel/helper-builder-react-jsx@7.0.0
├─ @babel/helper-call-delegate@7.1.0
├─ @babel/helper-create-class-features-plugin@7.2.1
├─ @babel/helper-define-map@7.1.0
├─ @babel/helper-explode-assignable-expression@7.1.0
├─ @babel/helper-hoist-variables@7.0.0
├─ @babel/helper-module-transforms@7.1.0
├─ @babel/helper-remap-async-to-generator@7.1.0
├─ @babel/helper-wrap-function@7.2.0
├─ @babel/helpers@7.2.0
├─ @babel/highlight@7.0.0
├─ @babel/parser@7.2.0
├─ @babel/plugin-external-helpers@7.2.0
├─ @babel/plugin-proposal-export-default-from@7.2.0
├─ @babel/plugin-syntax-class-properties@7.2.0
├─ @babel/plugin-syntax-dynamic-import@7.2.0
├─ @babel/plugin-syntax-export-default-from@7.2.0
├─ @babel/plugin-syntax-flow@7.2.0
├─ @babel/plugin-syntax-nullish-coalescing-operator@7.2.0
├─ @babel/plugin-syntax-object-rest-spread@7.2.0
├─ @babel/plugin-syntax-optional-catch-binding@7.2.0
├─ @babel/plugin-syntax-optional-chaining@7.2.0
├─ @babel/plugin-syntax-typescript@7.2.0
├─ @babel/plugin-transform-async-to-generator@7.2.0
├─ @babel/plugin-transform-block-scoped-functions@7.2.0
├─ @babel/plugin-transform-exponentiation-operator@7.2.0
├─ @babel/plugin-transform-member-expression-literals@7.2.0
├─ @babel/plugin-transform-object-assign@7.2.0
├─ @babel/plugin-transform-object-super@7.2.0
├─ @babel/plugin-transform-property-literals@7.2.0
├─ @babel/plugin-transform-react-jsx-source@7.2.0
├─ @babel/plugin-transform-regenerator@7.0.0
├─ @babel/plugin-transform-runtime@7.2.0
├─ @babel/plugin-transform-sticky-regex@7.2.0
├─ @babel/plugin-transform-typescript@7.2.0
├─ @babel/plugin-transform-unicode-regex@7.2.0
├─ @babel/register@7.0.0
├─ @babel/runtime@7.2.0
├─ accepts@1.3.5
├─ ansi-colors@1.1.0
├─ ansi-cyan@0.1.1
├─ ansi-escapes@3.1.0
├─ ansi-gray@0.1.1
├─ ansi-red@0.1.1
├─ ansi-styles@3.2.1
├─ ansi@0.3.1
├─ anymatch@2.0.0
├─ are-we-there-yet@1.1.5
├─ argparse@1.0.10
├─ arr-flatten@1.1.0
├─ array-filter@0.0.1
├─ array-map@0.0.0
├─ array-reduce@0.0.0
├─ array-slice@0.2.3
├─ art@0.10.3
├─ asap@2.0.6
├─ assign-symbols@1.0.0
├─ async-limiter@1.0.0
├─ async@2.6.1
├─ atob@2.1.2
├─ babel-plugin-syntax-trailing-function-commas@7.0.0-beta.0
├─ babel-preset-fbjs@3.1.0
├─ balanced-match@1.0.0
├─ base@0.11.2
├─ base64-js@1.3.0
├─ basic-auth@2.0.1
├─ big-integer@1.6.40
├─ bplist-creator@0.0.7
├─ bplist-parser@0.1.1
├─ brace-expansion@1.1.11
├─ braces@2.3.2
├─ bser@2.0.0
├─ buffer-crc32@0.2.13
├─ builtin-modules@1.1.1
├─ bytes@3.0.0
├─ cache-base@1.0.1
├─ caller-callsite@2.0.0
├─ caller-path@2.0.0
├─ callsites@2.0.0
├─ capture-exit@1.2.0
├─ chardet@0.4.2
├─ class-utils@0.3.6
├─ cli-cursor@2.1.0
├─ cli-width@2.2.0
├─ cliui@3.2.0
├─ code-point-at@1.1.0
├─ collection-visit@1.0.0
├─ color-convert@1.9.3
├─ color-name@1.1.3
├─ color-support@1.1.3
├─ commander@2.19.0
├─ commondir@1.0.1
├─ compressible@2.0.15
├─ compression@1.7.3
├─ concat-map@0.0.1
├─ concat-stream@1.6.2
├─ convert-source-map@1.6.0
├─ copy-descriptor@0.1.1
├─ core-js@2.6.0
├─ core-util-is@1.0.2
├─ cosmiconfig@5.0.7
├─ create-react-class@15.6.3
├─ cross-spawn@5.1.0
├─ debug@2.6.9
├─ decamelize@1.2.0
├─ decode-uri-component@0.2.0
├─ delegates@1.0.0
├─ destroy@1.0.4
├─ detect-newline@2.1.0
├─ dom-walk@0.1.1
├─ ee-first@1.1.1
├─ encoding@0.1.12
├─ end-of-stream@1.4.1
├─ envinfo@5.12.1
├─ error-ex@1.3.2
├─ errorhandler@1.5.0
├─ esprima@4.0.1
├─ esutils@2.0.2
├─ etag@1.8.1
├─ event-target-shim@1.1.1
├─ eventemitter3@3.1.0
├─ execa@0.7.0
├─ expand-brackets@2.1.4
├─ expand-range@1.8.2
├─ external-editor@2.2.0
├─ extglob@2.0.4
├─ fancy-log@1.3.3
├─ fbjs-css-vars@1.0.1
├─ fbjs-scripts@1.0.1
├─ figures@2.0.0
├─ filename-regex@2.0.1
├─ fill-range@4.0.0
├─ finalhandler@1.1.0
├─ find-cache-dir@1.0.0
├─ find-up@2.1.0
├─ for-in@1.0.2
├─ for-own@0.1.5
├─ fresh@0.5.2
├─ fs.realpath@1.0.0
├─ gauge@1.2.7
├─ get-caller-file@1.0.3
├─ get-stream@3.0.0
├─ get-value@2.0.6
├─ glob-base@0.3.0
├─ glob-parent@2.0.0
├─ glob@7.1.3
├─ global@4.3.2
├─ growly@1.3.0
├─ has-ansi@2.0.0
├─ has-flag@3.0.0
├─ has-unicode@2.0.1
├─ has-value@1.0.0
├─ has-values@1.0.0
├─ home-or-tmp@3.0.0
├─ hosted-git-info@2.7.1
├─ http-errors@1.6.3
├─ iconv-lite@0.4.24
├─ image-size@0.6.3
├─ import-fresh@2.0.0
├─ imurmurhash@0.1.4
├─ inflight@1.0.6
├─ inherits@2.0.3
├─ inquirer@3.3.0
├─ invariant@2.2.4
├─ invert-kv@1.0.0
├─ is-accessor-descriptor@1.0.0
├─ is-arrayish@0.2.1
├─ is-builtin-module@1.0.0
├─ is-data-descriptor@1.0.0
├─ is-descriptor@1.0.2
├─ is-directory@0.3.1
├─ is-dotfile@1.0.3
├─ is-equal-shallow@0.1.3
├─ is-fullwidth-code-point@1.0.0
├─ is-plain-object@2.0.4
├─ is-posix-bracket@0.1.1
├─ is-primitive@2.0.0
├─ is-promise@2.1.0
├─ is-windows@1.0.2
├─ isarray@1.0.0
├─ isexe@2.0.0
├─ jest-docblock@24.0.0-alpha.6
├─ jest-serializer@24.0.0-alpha.2
├─ jest-worker@24.0.0-alpha.2
├─ js-tokens@4.0.0
├─ js-yaml@3.12.0
├─ jsesc@2.5.2
├─ json-parse-better-errors@1.0.2
├─ json-stable-stringify@1.0.1
├─ json5@2.1.0
├─ jsonfile@2.4.0
├─ kind-of@3.2.2
├─ klaw@1.3.1
├─ lcid@1.0.0
├─ load-json-file@2.0.0
├─ locate-path@2.0.0
├─ lodash.pad@4.5.1
├─ lodash.padend@4.6.1
├─ lodash.padstart@4.6.1
├─ lru-cache@4.1.5
├─ make-dir@1.3.0
├─ makeerror@1.0.11
├─ map-visit@1.0.0
├─ math-random@1.0.1
├─ mem@1.1.0
├─ merge@1.2.1
├─ metro-babel-register@0.48.3
├─ metro-babel7-plugin-react-transform@0.48.3
├─ metro-config@0.48.3
├─ metro-memory-fs@0.48.3
├─ metro-minify-uglify@0.48.3
├─ metro-react-native-babel-preset@0.48.3
├─ metro-source-map@0.48.3
├─ metro@0.48.3
├─ mime-db@1.37.0
├─ mime-types@2.1.11
├─ mime@1.6.0
├─ min-document@2.19.0
├─ minimatch@3.0.4
├─ minimist@1.2.0
├─ mixin-deep@1.3.1
├─ mkdirp@0.5.1
├─ morgan@1.9.1
├─ mute-stream@0.0.7
├─ nanomatch@1.2.13
├─ negotiator@0.6.1
├─ nice-try@1.0.5
├─ node-int64@0.4.0
├─ node-modules-regexp@1.0.0
├─ node-notifier@5.3.0
├─ normalize-package-data@2.4.0
├─ normalize-path@2.1.1
├─ npmlog@2.0.4
├─ nullthrows@1.1.1
├─ number-is-nan@1.0.1
├─ object-assign@4.1.1
├─ object-copy@0.1.0
├─ object.omit@2.0.1
├─ once@1.4.0
├─ onetime@2.0.1
├─ opn@3.0.3
├─ optimist@0.6.1
├─ options@0.0.6
├─ os-locale@2.1.0
├─ os-tmpdir@1.0.2
├─ p-limit@1.3.0
├─ p-locate@2.0.0
├─ p-try@1.0.0
├─ parse-glob@3.0.4
├─ parse-json@4.0.0
├─ parse-node-version@1.0.0
├─ pascalcase@0.1.1
├─ path-exists@3.0.0
├─ path-is-absolute@1.0.1
├─ path-key@2.0.1
├─ path-parse@1.0.6
├─ path-type@2.0.0
├─ pegjs@0.10.0
├─ pirates@4.0.0
├─ pkg-dir@2.0.0
├─ plist@3.0.1
├─ plugin-error@0.1.2
├─ posix-character-classes@0.1.1
├─ preserve@0.2.0
├─ pretty-format@4.3.1
├─ private@0.1.8
├─ process-nextick-args@2.0.0
├─ process@0.5.2
├─ prop-types@15.6.2
├─ pseudomap@1.0.2
├─ pump@3.0.0
├─ randomatic@3.1.1
├─ range-parser@1.2.0
├─ react-clone-referenced-element@1.1.0
├─ react-deep-force-update@1.1.2
├─ react-devtools-core@3.4.3
├─ react-native@0.57.7
├─ react-proxy@1.1.8
├─ react-timer-mixin@0.13.4
├─ read-pkg-up@2.0.0
├─ read-pkg@2.0.0
├─ readable-stream@2.3.6
├─ regenerate-unicode-properties@7.0.0
├─ regenerator-runtime@0.11.1
├─ regenerator-transform@0.13.3
├─ regex-cache@0.4.4
├─ regexpu-core@4.4.0
├─ regjsgen@0.5.0
├─ regjsparser@0.6.0
├─ remove-trailing-separator@1.1.0
├─ require-directory@2.1.1
├─ require-main-filename@1.0.1
├─ resolve-from@3.0.0
├─ resolve-url@0.2.1
├─ resolve@1.8.1
├─ restore-cursor@2.0.0
├─ ret@0.1.15
├─ rimraf@2.6.2
├─ rsvp@3.6.2
├─ run-async@2.3.0
├─ rx-lite-aggregates@4.0.8
├─ rx-lite@4.0.8
├─ safer-buffer@2.1.2
├─ sane@3.1.0
├─ sax@1.1.6
├─ semver@5.6.0
├─ send@0.16.2
├─ serialize-error@2.1.0
├─ serve-static@1.13.2
├─ set-blocking@2.0.0
├─ set-value@2.0.0
├─ setprototypeof@1.1.0
├─ shebang-regex@1.0.0
├─ shell-quote@1.6.1
├─ shellwords@0.1.1
├─ signal-exit@3.0.2
├─ simple-plist@0.2.1
├─ slide@1.1.6
├─ snapdragon-node@2.1.1
├─ snapdragon-util@3.0.1
├─ source-map-resolve@0.5.2
├─ source-map-support@0.5.9
├─ source-map-url@0.4.0
├─ spdx-correct@3.1.0
├─ spdx-exceptions@2.2.0
├─ split-string@3.1.0
├─ sprintf-js@1.0.3
├─ stacktrace-parser@0.1.4
├─ static-extend@0.1.2
├─ statuses@1.3.1
├─ stream-buffers@2.2.0
├─ string_decoder@1.1.1
├─ string-width@1.0.2
├─ strip-ansi@3.0.1
├─ strip-bom@3.0.0
├─ supports-color@2.0.0
├─ temp@0.8.3
├─ throat@4.1.0
├─ through@2.3.8
├─ through2@2.0.5
├─ time-stamp@1.1.0
├─ tmp@0.0.33
├─ tmpl@1.0.4
├─ to-fast-properties@2.0.0
├─ to-regex-range@2.1.1
├─ trim-right@1.0.1
├─ typedarray@0.0.6
├─ uglify-es@3.3.9
├─ ultron@1.0.2
├─ unicode-canonical-property-names-ecmascript@1.0.4
├─ unicode-match-property-ecmascript@1.0.4
├─ unicode-match-property-value-ecmascript@1.0.2
├─ unicode-property-aliases-ecmascript@1.0.4
├─ union-value@1.0.0
├─ unpipe@1.0.0
├─ unset-value@1.0.0
├─ urix@0.1.0
├─ use@3.1.1
├─ util-deprecate@1.0.2
├─ utils-merge@1.0.1
├─ uuid@3.0.1
├─ validate-npm-package-license@3.0.4
├─ vary@1.1.2
├─ walker@1.0.7
├─ watch@0.18.0
├─ whatwg-fetch@3.0.0
├─ which-module@2.0.0
├─ wrap-ansi@2.1.0
├─ write-file-atomic@1.3.4
├─ xcode@1.0.0
├─ xmlbuilder@9.0.7
├─ xmldoc@0.4.0
├─ xpipe@1.0.5
├─ xtend@4.0.1
├─ y18n@3.2.1
└─ yargs-parser@7.0.0
Done in 148.50s.
Setting up new React Native app in E:\ReactNativeSpace\FirstProject
Adding React...
yarn add v1.12.3
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@1.2.4: The platform "win32" is incompatible with this module.
info "fsevents@1.2.4" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
success Saved 2 new dependencies.
info Direct dependencies
└─ react@16.6.1
info All dependencies
├─ react@16.6.1
└─ scheduler@0.11.3
Done in 7.48s.
Adding Jest...
yarn add v1.12.3
[1/4] Resolving packages...
warning jest > jest-cli > prompts > kleur@2.0.2: Please upgrade to kleur@3 or migrate to 'ansi-colors' if you prefer the old syntax. Visit <https://github.com/lukeed/kleur/releases/tag/v3.0.0\> for migration path(s).
[2/4] Fetching packages...
info fsevents@1.2.4: The platform "win32" is incompatible with this module.
info "fsevents@1.2.4" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning "metro-react-native-babel-preset > @babel/plugin-proposal-class-properties@7.2.1" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "metro-react-native-babel-preset > @babel/plugin-proposal-nullish-coalescing-operator@7.2.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "metro-react-native-babel-preset > @babel/plugin-proposal-object-rest-spread@7.2.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "metro-react-native-babel-preset > @babel/plugin-proposal-optional-catch-binding@7.2.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "metro-react-native-babel-preset > @babel/plugin-proposal-optional-chaining@7.2.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "metro-react-native-babel-preset > @babel/plugin-transform-flow-strip-types@7.2.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "metro-react-native-babel-preset > @babel/plugin-transform-modules-commonjs@7.2.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "metro-react-native-babel-preset > @babel/plugin-transform-arrow-functions@7.2.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "metro-react-native-babel-preset > @babel/plugin-transform-block-scoping@7.2.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "metro-react-native-babel-preset > @babel/plugin-transform-classes@7.2.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "metro-react-native-babel-preset > @babel/plugin-transform-computed-properties@7.2.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "metro-react-native-babel-preset > @babel/plugin-transform-destructuring@7.2.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "metro-react-native-babel-preset > @babel/plugin-transform-for-of@7.2.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "metro-react-native-babel-preset > @babel/plugin-transform-function-name@7.2.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "metro-react-native-babel-preset > @babel/plugin-transform-literals@7.2.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "metro-react-native-babel-preset > @babel/plugin-transform-parameters@7.2.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "metro-react-native-babel-preset > @babel/plugin-transform-react-display-name@7.2.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "metro-react-native-babel-preset > @babel/plugin-transform-react-jsx@7.2.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "metro-react-native-babel-preset > @babel/plugin-transform-shorthand-properties@7.2.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "metro-react-native-babel-preset > @babel/plugin-transform-spread@7.2.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "metro-react-native-babel-preset > @babel/plugin-transform-template-literals@7.2.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "metro-react-native-babel-preset > @babel/plugin-proposal-export-default-from@7.2.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "metro-react-native-babel-preset > @babel/plugin-syntax-dynamic-import@7.2.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "metro-react-native-babel-preset > @babel/plugin-syntax-export-default-from@7.2.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "metro-react-native-babel-preset > @babel/plugin-transform-exponentiation-operator@7.2.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "metro-react-native-babel-preset > @babel/plugin-transform-object-assign@7.2.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "metro-react-native-babel-preset > @babel/plugin-transform-react-jsx-source@7.2.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "metro-react-native-babel-preset > @babel/plugin-transform-regenerator@7.0.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "metro-react-native-babel-preset > @babel/plugin-transform-runtime@7.2.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "metro-react-native-babel-preset > @babel/plugin-transform-sticky-regex@7.2.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "metro-react-native-babel-preset > @babel/plugin-transform-typescript@7.2.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "metro-react-native-babel-preset > @babel/plugin-transform-unicode-regex@7.2.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning " > babel-jest@23.6.0" has unmet peer dependency "babel-core@^6.0.0 || ^7.0.0-0".
warning " > babel-jest@23.6.0" has unmet peer dependency "babel-core@^6.0.0 || ^7.0.0-0".
warning " > metro-react-native-babel-preset@0.50.0" has unmet peer dependency "@babel/core@*".
[4/4] Building fresh packages...
success Saved lockfile.
success Saved 131 new dependencies.
info Direct dependencies
├─ babel-jest@23.6.0
├─ jest@23.6.0
├─ metro-react-native-babel-preset@0.50.0
└─ react-test-renderer@16.6.1
info All dependencies
├─ acorn-globals@4.3.0
├─ acorn-walk@6.1.1
├─ acorn@5.7.3
├─ ajv@6.6.1
├─ append-transform@0.4.0
├─ array-equal@1.0.0
├─ arrify@1.0.1
├─ asn1@0.2.4
├─ astral-regex@1.0.0
├─ asynckit@0.4.0
├─ aws-sign2@0.7.0
├─ aws4@1.8.0
├─ babel-generator@6.26.1
├─ babel-helpers@6.24.1
├─ babel-jest@23.6.0
├─ babel-plugin-jest-hoist@23.2.0
├─ babel-register@6.26.0
├─ babel-template@6.26.0
├─ bcrypt-pbkdf@1.0.2
├─ browser-process-hrtime@0.1.3
├─ browser-resolve@1.11.3
├─ caseless@0.12.0
├─ ci-info@1.6.0
├─ cliui@4.1.0
├─ co@4.6.0
├─ combined-stream@1.0.7
├─ cssom@0.3.4
├─ cssstyle@1.1.1
├─ dashdash@1.14.1
├─ data-urls@1.1.0
├─ deep-is@0.1.3
├─ default-require-extensions@1.0.0
├─ delayed-stream@1.0.0
├─ detect-indent@4.0.0
├─ diff@3.5.0
├─ domexception@1.0.1
├─ ecc-jsbn@0.1.2
├─ es-abstract@1.12.0
├─ es-to-primitive@1.2.0
├─ escodegen@1.11.0
├─ estraverse@4.2.0
├─ expect@23.6.0
├─ extend@3.0.2
├─ extsprintf@1.3.0
├─ fast-deep-equal@2.0.1
├─ fast-levenshtein@2.0.6
├─ fileset@2.0.3
├─ forever-agent@0.6.1
├─ form-data@2.3.3
├─ getpass@0.1.7
├─ handlebars@4.0.12
├─ har-schema@2.0.0
├─ har-validator@5.1.3
├─ has-symbols@1.0.0
├─ html-encoding-sniffer@1.0.2
├─ http-signature@1.2.0
├─ is-callable@1.1.4
├─ is-date-object@1.0.1
├─ is-finite@1.0.2
├─ is-generator-fn@1.0.0
├─ is-regex@1.0.4
├─ is-symbol@1.0.2
├─ is-typedarray@1.0.0
├─ is-utf8@0.2.1
├─ isstream@0.1.2
├─ istanbul-api@1.3.7
├─ istanbul-lib-hook@1.2.2
├─ istanbul-lib-report@1.1.5
├─ istanbul-lib-source-maps@1.2.6
├─ istanbul-reports@1.5.1
├─ jest-changed-files@23.4.2
├─ jest-cli@23.6.0
├─ jest-each@23.6.0
├─ jest-environment-node@23.4.0
├─ jest-leak-detector@23.6.0
├─ jest-resolve-dependencies@23.6.0
├─ jest-runner@23.6.0
├─ jest-serializer@23.0.1
├─ jest-watcher@23.4.0
├─ jest@23.6.0
├─ jsdom@11.12.0
├─ json-schema-traverse@0.4.1
├─ json-schema@0.2.3
├─ json-stringify-safe@5.0.1
├─ jsprim@1.4.1
├─ kleur@2.0.2
├─ left-pad@1.3.0
├─ leven@2.1.0
├─ levn@0.3.0
├─ metro-babel7-plugin-react-transform@0.50.0
├─ metro-react-native-babel-preset@0.50.0
├─ natural-compare@1.4.0
├─ nwsapi@2.0.9
├─ oauth-sign@0.9.0
├─ object-keys@1.0.12
├─ object.getownpropertydescriptors@2.0.3
├─ optionator@0.8.2
├─ parse5@4.0.0
├─ performance-now@2.1.0
├─ pinkie@2.0.4
├─ pn@1.1.0
├─ prompts@0.1.14
├─ psl@1.1.29
├─ qs@6.5.2
├─ react-is@16.6.3
├─ react-test-renderer@16.6.1
├─ repeating@2.0.1
├─ request-promise-core@1.1.1
├─ request-promise-native@1.0.5
├─ request@2.88.0
├─ resolve-cwd@2.0.0
├─ sane@2.5.2
├─ sisteransi@0.1.1
├─ sshpk@1.15.2
├─ stack-utils@1.0.2
├─ stealthy-require@1.1.1
├─ symbol-tree@3.2.2
├─ test-exclude@4.2.3
├─ tough-cookie@2.5.0
├─ tunnel-agent@0.6.0
├─ tweetnacl@0.14.5
├─ uglify-js@3.4.9
├─ uri-js@4.2.2
├─ util.promisify@1.0.0
├─ verror@1.10.0
├─ w3c-hr-time@1.0.1
├─ whatwg-encoding@1.0.5
├─ whatwg-mimetype@2.3.0
├─ whatwg-url@6.5.0
├─ xml-name-validator@3.0.0
└─ yargs-parser@9.0.2
Done in 51.52s.
To run your app on iOS:
   cd E:\ReactNativeSpace\FirstProject
   react-native run-ios
   - or -
   Open ios\FirstProject.xcodeproj in Xcode
   Hit the Run button
To run your app on Android:
   cd E:\ReactNativeSpace\FirstProject
   Have an Android emulator running (quickest way to get started), or a device connected
   react-native run-android
以上创建可能时间有点长耐心等待。

--关联虚拟机
adb.exe connect 127.0.0.1:62001

C:\Users\Administrator>adb
Android Debug Bridge version 1.0.40
Version 4986621
Installed as D:\Android\Sdk\platform-tools\adb.exe

global options:
 -a         listen on all network interfaces, not just localhost
 -d         use USB device (error if multiple devices connected)
 -e         use TCP/IP device (error if multiple TCP/IP devices available)
 -s SERIAL  use device with given serial (overrides $ANDROID_SERIAL)
 -t ID      use device with given transport id
 -H         name of adb server host [default=localhost]
 -P         port of adb server [default=5037]
 -L SOCKET  listen on given socket for adb server [default=tcp:localhost:5037]

general commands:
 devices [-l]             list connected devices (-l for long output)
 help                     show this help message
 version                  show version num

networking:
 connect HOST[:PORT]      connect to a device via TCP/IP [default port=5555]
 disconnect [HOST[:PORT]]
     disconnect from given TCP/IP device [default port=5555], or all
 forward --list           list all forward socket connections
 forward [--no-rebind] LOCAL REMOTE
     forward socket connection using:
       tcp:<port> (<local> may be "tcp:0" to pick any open port)
       localabstract:<unix domain socket name>
       localreserved:<unix domain socket name>
       localfilesystem:<unix domain socket name>
       dev:<character device name>
       jdwp:<process pid> (remote only)
 forward --remove LOCAL   remove specific forward socket connection
 forward --remove-all     remove all forward socket connections
 ppp TTY [PARAMETER...]   run PPP over USB
 reverse --list           list all reverse socket connections from device
 reverse [--no-rebind] REMOTE LOCAL
     reverse socket connection using:
       tcp:<port> (<remote> may be "tcp:0" to pick any open port)
       localabstract:<unix domain socket name>
       localreserved:<unix domain socket name>
       localfilesystem:<unix domain socket name>
 reverse --remove REMOTE  remove specific reverse socket connection
 reverse --remove-all     remove all reverse socket connections from device

file transfer:
 push [--sync] LOCAL... REMOTE
     copy local files/directories to device
     --sync: only push files that are newer on the host than the device
 pull [-a] REMOTE... LOCAL
     copy files/dirs from device
     -a: preserve file timestamp and mode
 sync [all|data|odm|oem|product|system|vendor]
     sync a local build from $ANDROID_PRODUCT_OUT to the device (default all)
     -l: list but don't copy

shell:
 shell [-e ESCAPE] [-n] [-Tt] [-x] [COMMAND...]
     run remote shell command (interactive shell if no command given)
     -e: choose escape character, or "none"; default '~'
     -n: don't read from stdin
     -T: disable PTY allocation
     -t: force PTY allocation
     -x: disable remote exit codes and stdout/stderr separation
 emu COMMAND              run emulator console command

app installation:
 install [-lrtsdg] [--instant] PACKAGE
 install-multiple [-lrtsdpg] [--instant] PACKAGE...
     push package(s) to the device and install them
     -l: forward lock application
     -r: replace existing application
     -t: allow test packages
     -s: install application on sdcard
     -d: allow version code downgrade (debuggable packages only)
     -p: partial application install (install-multiple only)
     -g: grant all runtime permissions
     --instant: cause the app to be installed as an ephemeral install app
 uninstall [-k] PACKAGE
     remove this app package from the device
     '-k': keep the data and cache directories

backup/restore:
   to show usage run "adb shell bu help"

debugging:
 bugreport [PATH]
     write bugreport to given PATH [default=bugreport.zip];
     if PATH is a directory, the bug report is saved in that directory.
     devices that don't support zipped bug reports output to stdout.
 jdwp                     list pids of processes hosting a JDWP transport
 logcat                   show device log (logcat --help for more)

security:
 disable-verity           disable dm-verity checking on userdebug builds
 enable-verity            re-enable dm-verity checking on userdebug builds
 keygen FILE
     generate adb public/private key; private key stored in FILE,
     public key stored in FILE.pub (existing files overwritten)

scripting:
 wait-for[-TRANSPORT]-STATE
     wait for device to be in the given state
     State: device, recovery, sideload, or bootloader
     Transport: usb, local, or any [default=any]
 get-state                print offline | bootloader | device
 get-serialno             print <serial-number>
 get-devpath              print <device-path>
 remount                  remount partitions read-write
 reboot [bootloader|recovery|sideload|sideload-auto-reboot]
     reboot the device; defaults to booting system image but
     supports bootloader and recovery too. sideload reboots
     into recovery and automatically starts sideload mode,
     sideload-auto-reboot is the same but reboots after sideloading.
 sideload OTAPACKAGE      sideload the given full OTA package
 root                     restart adbd with root permissions
 unroot                   restart adbd without root permissions
 usb                      restart adb server listening on USB
 tcpip PORT               restart adb server listening on TCP on PORT

internal debugging:
 start-server             ensure that there is a server running
 kill-server              kill the server if it is running
 reconnect                kick connection from host side to force reconnect
 reconnect device         kick connection from device side to force reconnect
 reconnect offline        reset offline/unauthorized devices to force reconnect

environment variables:
 $ADB_TRACE
     comma-separated list of debug info to log:
     all,adb,sockets,packets,rwx,usb,sync,sysdeps,transport,jdwp
 $ADB_VENDOR_KEYS         colon-separated list of keys (files or directories)
 $ANDROID_SERIAL          serial number to connect to (see -s)
 $ANDROID_LOG_TAGS        tags to be used by logcat (see logcat --help)



E:\ReactNativeSpace>npm
编译并运行 React Native 应用
确保你先运行了模拟器或者连接了真机,
E:\ReactNativeSpace>cd FirstProject
--不需要每次执行,连接第一次执行
F:\ReactNativeSpace>FirstProject>react-native run-android
--执行react-native start
F:\ReactNativeSpace>FirstProject>react-native start

 

 类似资料: