Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Introduction to React Native Implementing React Native Scenes and Routing

Where do we type react-native run-android? In the folder of the project or ...?

What about installing npm react native packages before that? Where should we type those commands ? for example npm i -g react-native-run-android...and npm install react-native. Can you please explain more about the commands needed for every project we create and the npm packages we have to install?

2 Answers

I know sometimes the videos miss key information since no one is perfect, but that's what the community is for :)

So make sure one day you pay it forward as well. Anyway

You need to have the pre-requirements installed, (nodejs homebrew etc)
** note ** I already had nodeJs installed, so I just installed homebrew from the website, and followed along from there.

--------------------------------------------Pre reqs Start--------------------------------------------------------------------------------

Here's the instructions from the treehouse course shown in a previous video(https://teamtreehouse.com/library/basics-of-react-native) below :

The Requirements are: Requirements for Course are • Homebrew, • Latest Version of Xcode, • Genymotion ( for android), • React Native Create App,

Homebrew official link: https://brew.sh/

How to install Homebrew:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

After installing homebrew, • Install Node.js and NPM. Type in terminal:

brew install node

• Install Watchman ( a tool for developing in react native )n. Type in terminal:

brew install watchman

--------------------------------------------Pre reqs end--------------------------------------------------------------------------------

Now that you have the pre-reqs installed, in order to follow along you need to have react installed globally on your machine:

• Install React Native CLI. Type in terminal:

npm install -g react-native-cli

Some students may have to use sudo to install global npm package. If command above fails try typing in terminal:

sudo npm install -g react-native-cli

Once react-native cli is installed, navigate to your project folder in the terminal using cd then once your sure youre there

you have to do

npm install

which I think installs react to your project.

then open xcode and do this: https://stackoverflow.com/questions/39778607/error-running-react-native-app-from-terminal-ios

"In Xcode, select Xcode menu, then Preferences, then Locations tab. Select your Xcode version from the dropdown and exit Xcode."

THEN, FINALLY! you can do:

react-native run-ios

or the android version.

Note* if you're creating a new project from scratch, read this: https://facebook.github.io/react-native/docs/getting-started.html

You can specify which version if iphone you want using this:

react-native run-ios --simulator="iPhone X"

Reference: https://facebook.github.io/react-native/docs/running-on-simulator-ios.html

Also, make sure you look into this! https://expo.io/

Thank you for the answer! Appreciate your time! :)

It's nothing :), I am on the same path as you. Retyping this helped me as much as it helped you. Don't forget to pay it forward, share the karma, and help anyone else along the way!