【问题标题】:React Native bundle error : Module `scheduler` does not exist in the Haste module mapReact Native 包错误:Haste 模块映射中不存在模块`scheduler`
【发布时间】:2019-11-16 12:16:36
【问题描述】:

在我的 react native 项目中,如果我运行捆绑命令,它会失败并出现上述错误。

命令:

`sudo react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/`

错误:

error Unable to resolve module 'scheduler' from '/home/buddhi/Buddhi/my-dev-environment/html/react-apps/mobile-64/node_modules/react-native/Libraries/Renderer/oss/ReactNativeRenderer-prod.js': Module 'scheduler' does not exist in the Haste module map

This might be related to https://github.com/facebook/react-native/issues/4968
To resolve try the following:
  1. Clear watchman watches: 'watchman watch-del-all'.
  2. Delete the 'node_modules' folder: 'rm -rf node_modules && npm install'.
  3. Reset Metro Bundler cache: 'rm -rf /tmp/metro-bundler-cache-*' or 'npm start -- --reset-cache'.
  4. Remove haste cache: 'rm -rf /tmp/haste-map-react-native-packager-*'.. Run CLI with --verbose flag for more details.

版本:

  • “反应”:“16.8.3”
  • “react-native”:“0.59.0”
  • “npm”:6.9.0
  • “节点”:10.16.0

当我使用 react-native 0.57.2 运行相同的命令时,它运行完美。 (请注意,我需要使用 react native 0.59.0 版本来获得应用程序的 android x64 架构支持)

  1. 我已经尝试了错误中提到的步骤。
  2. 我尝试多次删除/node_modulesnpm install
  3. npm start --reset-cache之后尝试。

问题依然存在。

我可以看到的变化是,在 react-native 版本 0.59.0 中有 var scheduler = require("scheduler") 行,在错误中提到的文件 ReactNativeRenderer-prod.js 中。但是在 react-native 版本 0.57.2 中没有使用它。

我很确定这是由 npm 引起的,而不是 react-native 版本的问题。是吗?

无法弄清楚为什么它不在提到的加速模块地图中,以及加速模块地图到底是什么?我找不到足够的信息来支持这个问题。

任何帮助表示赞赏。询问更多信息。

【问题讨论】:

  • 嘿,你还有这个问题吗?
  • 是的,但我通过将依赖项一个一个迁移到工作副本来解决它。但是对我来说这个问题没有解决方案。
  • 就我而言,我有一个遗留的rn-cli.config.js 文件冲突。将其删除并将其内容添加到 Metro conf。就是这样。
  • 这可能是一个缓存问题吗,我正在研究这个问题,但仍然不知道确切的问题是什么。

标签: node.js reactjs react-native npm


【解决方案1】:

如果您使用的是 expo,请确保您的 exporeact-native 版本如下:

"expo": "^35.0.0", "react": "16.8.3", "react-native": "https://github.com/expo/react-native/archive/sdk-35.0.0.tar.gz",

只有这种组合对我有用。

【讨论】:

  • 很抱歉,但不能向任何人推荐使用确切版本。他们将永远无法升级。
猜你喜欢
  • 1970-01-01
  • 2020-01-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-12-18
  • 1970-01-01
  • 2020-12-18
  • 2020-02-12
相关资源
最近更新 更多