如何使用 Yarn 创建 React Native 项目? [英] How do I create a React Native project using Yarn?

查看:44
本文介绍了如何使用 Yarn 创建 React Native 项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 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后,控制台关闭.

错误日志显示:

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 全局安装 react-native-cli,而不是 yarn add global 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 项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆