问题描述
我正在Windows 7(64位)计算机上的DOS控制台中运行以下命令.
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
运行react-native init sample
后,控制台已关闭.
After running react-native init sample
, the console was closed.
错误日志显示:
D:\Mobile>"$basedir/../../Users/pramaswamy/AppData/Local/Yarn/.global/node_modules/.bin/react-native.cmd" "$@"
D:\Mobile>exit $?
推荐答案
我认为您在添加全局依赖项时出错,因此不需要在全局或本地安装react-native
. react-native init
将创建一个package.json
,其中react-native
被列为依赖项.
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.
您应该能够通过yarn global add react-native-cli
而不是yarn add global react-native-cli
全局安装react-native-cli
.
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
这篇关于如何使用Yarn创建一个React Native项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!