How do I create a React Native project using Yarn?

Prabhakaran Ramaswamy picture Prabhakaran Ramaswamy · Oct 13, 2016 · Viewed 80.5k times · Source

I am running the following commands in the DOS console on a Windows 7 (64-bit) machine.

npm install -g yarn
yarn add global react-native
yarn add global react-native-cli

react-native init sample

After running react-native init sample, the console was closed.

The error log shows:

D:\Mobile>"$basedir/../../Users/pramaswamy/AppData/Local/Yarn/.global/node_modules/.bin/react-native.cmd"   "$@" 

D:\Mobile>exit $? 

Answer

Jason Turner picture Jason Turner · Oct 19, 2016

I think you're adding global dependencies wrong, and you shouldn't need to install react-native, globally or locally. react-native init will create a package.json with react-native listed as a dependency.

You should be able to install react-native-cli globally with yarn global add react-native-cli, not yarn add global react-native-cli.

You should be fine with running the following:

npm install -g yarn
yarn global add react-native-cli
react-native init sample