Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
321 views
in Technique[技术] by (71.8m points)

android - How do I create a React Native project using Yarn?

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 $? 
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...