Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Preview
Start a free Courses trial
to watch this video
In this video, you will install Create React Native App globally and create a new React Native project.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
To get started building
your React Native app,
0:00
you'll need to install create React Native
app globally using either NPM or Yarn.
0:02
I'm going to use NPM.
0:07
So in my terminal,
I'll run the command npm install
0:09
-g followed by create-react-native-app.
0:14
Now it's recommended that
you have Node version 6 or
0:18
later installed in your computer and
that you use npm version 3 or 4.
0:22
You see, as I'm recording this video,
0:27
create-react-native-app does not
work with npm 5 due to bugs in npm.
0:29
But remember, you also have the option
of using a recent version of Yarn.
0:34
Once create-react-native-app is installed,
you create a new react native project
0:38
with the command create-react-native-app,
followed by the name of your project.
0:44
So I'll navigate to my desktop and
run create-react-native-app and
0:49
I'll name my project myNativeApp.
0:56
Running this command,
begins installing the dependencies and
1:01
files needed to build you project.
1:04
Now it might take a little bit to
complete the installation, but
1:06
once it's complete you'll see
this success in the console,
1:10
letting you know that tour project was
successfully created at this location.
1:13
And it says that inside that directory,
you can run several commands.
1:18
These instructions list five important
commands for create-react-native-app.
1:23
Start, run iOS, run android,
test, and eject.
1:27
So, for example, the start command starts
the development server, that way you
1:33
can run and preview your app on a physical
device or in iOS or android emulator.
1:38
Now, the next who commands, run iOS and
1:43
run android are like npm start in
that they start the dev server but
1:46
they are going to open your
app in a device simulator.
1:51
So if you have Xcode with the iOS
simulator installed on your Mac,
1:55
run iOS will start the development server
and load your app in its iOS simulator.
1:59
And run android is going to open your app
on a connected android device or emulator.
2:05
But keep in mind that this would
require installing Android Studio on
2:11
your computer, or
an Android emulator like Genymotion.
2:15
The test command starts the test runner.
2:20
This lets you start testing your
app with gest as you build it.
2:23
And the command npm run eject will
start the process of ejecting or taking
2:27
your app out of create-react-native-app
set up and build scripts, which lets
2:32
you build using native code and completely
customize your project configuration.
2:36
You're gonna learn more about the test and
eject commands in a later video.
2:41
But for now, create-react-native-app
suggest that we navigate to our new
2:46
myNativeApp folder and run npm start
to start the development server.
2:50
So, let's do that now.
2:55
All right, now that we're running the app,
in the next video, you'll see how simple
3:03
create-react-native-app let's
you build and
3:07
preview your app on a physical device,
as well as in iOS and Android simulators.
3:09
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up