我在Windows 7(64位)计算机上的DOS控制台中运行以下命令.

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

react-native init sample

运行react-native init sample后,控制台关闭.

错误日志(log)显示:

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列为依赖项.

你应该能够用yarn global add react-native-cli而不是yarn add global react-native-cli在全局安装react-native-cli.

您应该可以运行以下命令:

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

React-native相关问答推荐

如何停止在Expo路由中将新文件显示为菜单列表?

有人可以帮我实现 Font.loadAsync

如何解决Readonly<{}> 类型上不存在属性 navigation&

React Native 的 Firebase 初始错误(无法读取未定义的属性getItem)

如何将谷歌反向地理编码与 React Native Expo 结合使用?

React Native:在 ScrollView contentContainerStyle 上设置 flex:1 会导致组件重叠

React-native -run-ios 错误无法构建 iOS 元素.我们运行了xcodebuild命令,但它以错误代码 65 退出

React-native 解码 base64 编码字符串

如何使用 InteractionManager.runAfterInteractions 使导航器过渡更快

Test suite无法运行 TypeError:Cannot read property ‘default’ of undefined

React native - 创建单例模式的最佳方式

props验证中缺少 React Navigation 'navigation'

Android 依赖 'com.google.android.gms:play-services-stats' 的编译(16.0.1)和运行时(17.0.0)类路径有不同的版本

ENOENT: no such file or directory, 打开 'android/app/src/main/assets/index.android.bundle'

[React-Native][Jest]SyntaxError: Unexpected token import

react-native平面列表初始滚动到底部

在不使用 3rd 方库的情况下,在react-native中显示主屏幕之前显示启动画面

列之间的 React Native FlatList 分隔符

Gradlew bundleRelease 不会在 react-native 中生成发布 apk

React-native iOS 不显示图像(pod 问题)