react-native/docs/QuickStart-GettingStarted.md
Héctor Ramos 8324e92f76 Streamline Getting Started Instructions
Summary:
The Getting Started guide is one of the first documents a new user will encounter. This pull request aims to minimize the amount of time it takes to get a React Native app up and running.

* The original section title, "Required prerequisites", is redundant. "Installing React Native" is a better description of what this section is about.
* Detailed installation instructions for each of the required tools are delegated to the first party instructions where available.
* If the installation instructions already take care of installing the latest version, there's no need to warn the user about the minimum required version.

* Assume the user is familiar with Homebrew or Chocolatey, and defer installation instructions to the package manager's website. The installation and explanation of what a package manager is is out of scope within this document.
* Link to Node.js package manager instructions and let savvy Linux users use the pack
Closes https://github.com/facebook/react-native/pull/8010

Differential Revision: D3407029

Pulled By: JoelMarcey

fbshipit-source-id: c8b25d5b176c40eb58e5d7d3c6f13d43cde65166
2016-06-08 13:28:34 -07:00

13 KiB

id title layout category permalink next
quick-start-getting-started Getting Started docs Quick Start docs/getting-started.html tutorial-core-components
Target: iOS Android Development OS: Mac Linux Windows

Unsupported

Unfortunately, Apple only lets you develop for iOS on a Mac machine. Please check out the Android instructions instead.

Installing React Native

There's a few things you need to install first. You will need Node.js, the React Native command line tools, Watchman, and Xcode.

Installing React Native

There's a few things you need to install first. You will need Node.js, the React Native command line tools, Watchman, and Android Studio.

Node.js

We recommend installing Node.js via Homebrew, a popular package manager for OS X:

brew install node

React Native command line tools

Use Node's package manager to install the React Native command line tools. These will allow you to easily create your first React Native project.

npm install -g react-native-cli

If you see the error, EACCES: permission denied, please run the command: sudo npm install -g react-native-cli.

Watchman

Watchman is a tool by Facebook for watching changes in the filesystem. It is recommended you install it for better performance.

brew install watchman

Xcode

You can install Xcode via the Mac App Store, or download it directly from the Apple Developer portal.

Android Studio

Download and install Android Studio.

Gradle Daemon

While optional, enabling Gradle Daemon will greatly improve incremental build times for changes in Java code.

Installing React Native

There's a few things you need to install first. You will need Node.js, the React Native command line tools, Watchman, and Android Studio.

Node.js

Follow the installation instructions for your Linux distribution to install Node.js 4 or newer.

We recommend installing Node.js via Chocolatey, a popular package manager for Windows. Open a Command Prompt as Administrator, then run the following command:

choco install nodejs.install
Python

The React Native command line tools require Python2. Install it using Chocolatey:

choco install python2

React Native command line tools

Use Node's package manager to install the React Native command line tools. These will allow you to easily create your first React Native project.

npm install -g react-native-cli

If you see the error, EACCES: permission denied, please run the command: sudo npm install -g react-native-cli.

Android Studio

Download and install Android Studio.

Watchman

Watchman is a tool by Facebook for watching changes in the filesystem. It is recommended you install it for better performance. You can follow the Watchman installation guide to compile and install from source.

Gradle Daemon

While optional, enabling Gradle Daemon will greatly improve incremental build times for changes in Java code.

Testing your React Native Installation

Use the React Native command line tools to generate a new React Native project called "AwesomeProject", then run react-native run-ios inside the newly created folder.

react-native init AwesomeProject
cd AwesomeProject
react-native run-ios

If everything is set up correctly, you should see your new app running in the iOS Simulator shortly.

You can also open the AwesomeProject folder in Nuclide and run the application, or open ios/AwesomeProject.xcodeproj and hit the Run button in Xcode.

Use the React Native command line tools to generate a new React Native project called "AwesomeProject", then run react-native run-android inside the newly created folder.

react-native init AwesomeProject
cd AwesomeProject
react-native run-android

If everything is set up correctly, you should see your new app running in your Android emulator shortly.

You can also open the AwesomeProject folder in Nuclide and run the application.

Modifying your app

Now that you have successfully run the app, let's modify it.

  • Open index.ios.js in your text editor of choice and edit some lines.
  • Hit Command⌘ + R in your iOS Simulator to reload the app and see your change!
  • Open index.android.js in your text editor of choice and edit some lines.
  • Press the R key twice or select Reload from the Developer Menu to see your change!

That's it!

Congratulations! You've successfully run and modified your first React Native app.

Testing your React Native Installation

Use the React Native command line tools to generate a new React Native project called "AwesomeProject", then run react-native run-android inside the newly created folder.

react-native init AwesomeProject
cd AwesomeProject
react-native run-android

If everything is set up correctly, you should see your new app running in your Android emulator shortly.

A common issue is that the packager is not started automatically when you run react-native run-android. You can start it manually using react-native start.

If you hit a ERROR Watcher took too long to load on Windows, try increasing the timeout in this file (under your node_modules/react-native/).

Modifying your app

Now that you have successfully run the app, let's modify it.

  • Open index.android.js in your text editor of choice and edit some lines.
  • Press the R key twice or select Reload from the Developer Menu to see your change!

That's it!

Congratulations! You've successfully run and modified your first React Native app.

Common Followups

Common Followups