node.js - React Native bundle 错误 : Module `scheduler` does not exist in the Haste module map

标签 node.js reactjs react-native npm

在我的 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.

版本:

  • “ react ”:“16.8.3”
  • "react-native": "0.59.0"
  • “npm”:6.9.0
  • “Node ”: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中,在文件 ReactNativeRenderer-prod.txt 中,有一行 var Scheduler = require("scheduler") 。 js 如错误中所述。但在react-native版本0.57.2中它没有被使用。

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

不明白为什么它不在提到的急速模块图中,而急速模块图到底是什么?我找不到足够的信息来支持该问题。

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

最佳答案

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

"博览会": "^35.0.0", “ react ”:“16.8.3”, “react-native”:“https://github.com/expo/react-native/archive/sdk-35.0.0.tar.gz”,

只有这个组合对我有用。

关于node.js - React Native bundle 错误 : Module `scheduler` does not exist in the Haste module map,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56910233/

相关文章:

ios - React Native - npx react-native run-ios 在初始化项目后不起作用

node.js - 在windows下安装nodejs出错

node.js - react 路由器部署非静态

node.js - NODEJS 从字节字符串创建 zip

javascript - 没有变化的纯渲染元素渲染 ReactJS

reactjs - 除了其他 Prop 之外,还向子组件传递额外的类名

ios - React Native,应用程序在模拟器上运行,但不能在真实的 iPhone 上运行

android - React native 应用程序在 IOS 13 版本设备中崩溃

node.js - Node : http-proxy redirect to available server

node.js - Mongoose 不尊重架构并插入错误的数据类型