typescript - Android Build 上 node_modules/react-native/index.js : Unexpected token, 中的 React Native SyntaxError 预期 "{"(13:7)

标签 typescript react-native react-native-android

我已经初始化了一个 react-native-project 并将其转换为使用 TypeScript。我还将项目设置为编译为 web、android 和 ios。安装 Webpack 以启动 Web 版本。我在 Web 和 iOS 上一切正常,但是当我运行 yarn android 并构建到 android 时,我在 Metro 窗口和来自 node_modules 下 react-native 项目中的 index.js 文件的 android 模拟器上收到语法错误。

这仅发生在 Android 上。我已经安装了许多 babel 插件和预设,所以我不确定为什么这个 index.js 文件不适用于 Android,但在 iOS 上可以正常工作。任何帮助都会很棒。我已将项目上传到公共(public)存储库中。

我在 github 存储库中有可用的入门项目,因此您可以下拉我的确切设置。
https://github.com/hybridmindset/liveapp

我正在运行
Mac OS 版本 Catalina 10.15.4
节点 v14.0.0

Metro server window with Error

Android Simulator Window with Error

最佳答案

这可能会有所帮助。
这是我的.babelrc:
{
“预设”:[
"@babel/preset-env",
"@babel/preset-react",
“@babel/预设流”
]
}

https://github.com/babel/babel/issues/9351

关于typescript - Android Build 上 node_modules/react-native/index.js : Unexpected token, 中的 React Native SyntaxError 预期 "{"(13:7),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61537619/

相关文章:

javascript - react native : State seems to retain previous state even after reload on the simulator

react-native - React Native 相机第一次工作,然后在 Android 设备中无法工作(黑屏)

javascript - 如何使用 Google Maps DirectionsService.route() 函数中的 Angular 双向绑定(bind)?

javascript - 使用电子邮件和密码登录后,我需要将电子邮件传递到下一个页面,以便从 API 检索用户数据。 ( react )

react-native - 在 react-native 中对 android 和 IOS 发出警报

android - 当屏幕锁定在 native 上时如何显示来电

react-native - 如何修复 : A problem occurred configuring project

javascript - 将 jQuery 插件转换为 TypeScript

javascript - 多个 API 请求

javascript - Angular5 服务不发送数据?