构建 JS 包时的 Expo 启动错误:在 HMRClient.js 中进行类型转换

Posted

技术标签:

【中文标题】构建 JS 包时的 Expo 启动错误:在 HMRClient.js 中进行类型转换【英文标题】:Expo start error on building JS bundle : type cast in HMRClient.js 【发布时间】:2021-05-12 01:25:16 【问题描述】:

问题:

我最近在我的 expo 项目 (React Native) 中遇到了阻塞问题。

类型转换表达式应该用括号括起来

我检查了我的代码,没有发现任何会导致此问题的更改。

当我输入说明以使用 MetroBundler 启动博览会构建(shell)时,它总是抛出错误。

    expo start

    Expo DevTools is running at http://localhost:19002 Opening DevTools in the browser... (press shift-d to disable) Starting Metro Bundler

    错误

Failed building javascript bundle.
SyntaxError: C:\xamppN\htdocs\mobile-new\node_modules\react-native\Libraries\Utilities\HMRClient.js: The type cast expression is expected to be wrapped with parenthesis (284:31)

  282 | function flushEarlyLogs(client) 
  283 |   try 
> 284 |     pendingLogs.forEach(([level: LogLevel, data: Array<mixed>]) => 
      |                                ^
  285 |       HMRClient.log(level, data);
  286 |     );
  287 |    finally 

类型转换表达式应该用括号括起来

我试过了:

编辑目标文件,它在节点模块内,不是 非常有效 如果我以后必须安装纱线。 删除所有 node_modules 并再次安装没有成功 将 expo 更新到最新版本,没有改变任何东西,同样的错误

更多信息:

package.json:

 "dependencies": 
    "antd": "^3.23.2",
    "expo": "^39.0.0", 
    "expo-asset": "~8.2.0",
    "expo-av": "~8.6.0",
    "expo-barcode-scanner": "~9.0.0",
    "expo-cli": "^3.27.14",
    "expo-constants": "~9.2.0",
    "expo-localization": "~9.0.0",
    "expo-permissions": "~9.3.0",
    "expo-secure-store": "~9.2.0",
    "expo-updates": "~0.3.3",
    "expokit": "31.0.2",
    "moment": "^2.22.2",
    "node-forge": "^0.10.0",
    "npm": "^6.14.8",
    "react": "16.13.1",
    "react-datetime-inputs": "^0.0.6",
    "react-mixin": "^2.0.2",
    "react-native": "https://github.com/expo/react-native/archive/sdk-39.0.0.tar.gz",
    "react-native-create-bridge": "^2.0.1",
    "react-native-dialog": "^5.6.0",
    "react-native-dialog-input": "^1.0.7",
    "react-native-gesture-handler": "~1.7.0",
    "react-native-imei": "^0.1.2",
    "react-native-modal-datetime-picker": "^7.5.0",
    "react-native-pay-password": "^0.0.2",
    "react-native-reanimated": "~1.13.0",
    "react-native-sentry": "^0.43.2",
    "react-native-sha1": "^1.2.3",
    "react-navigation": "^4.0.6",
    "react-navigation-drawer": "^2.2.2",
    "react-select": "^3.0.4",
    "react-timer-mixin": "^0.13.4",
    "sentry-expo": "~2.0.0",
    "yarn": "^1.16.0"

【问题讨论】:

我放弃了世博会,不值得我花时间 【参考方案1】:

这是"yarn": "^1.16.0" and "npm": "^6.14.8"之间的冲突。

你应该选择ONE包管理器并避免交叉依赖

【讨论】:

以上是关于构建 JS 包时的 Expo 启动错误:在 HMRClient.js 中进行类型转换的主要内容,如果未能解决你的问题,请参考以下文章

首次运行应用程序时的 Expo 问题

在我构建 Android 时的 Expo(未找到 `keytool` 实用程序)

无法清除此错误 - 安装 Expo CLI 时的 ENOTEMPTY

06HMR热加载

未捕获的错误:[HMR] 热模块更换已禁用

安装laravel包时的错误列表