在我的 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架构支持)
- 我已尝试了错误中提到的步骤。
- 我多次尝试删除
/node_modules
和npm install
。 - 在
npm start --reset-cache
后尝试过。
问题仍然存在。
我所看到的变化是,在react-native版本0.59.0中,在文件 ReactNativeRenderer-prod.txt 中,有一行
如错误中所述。但在react-native版本0.57.2中它没有被使用。var Scheduler = require("scheduler")
。 js
我很确定这是由npm
引起的,而不是react-native版本的问题。是吗?
不明白为什么它不在提到的急速模块图中,而急速模块图到底是什么?我找不到足够的信息来支持该问题。
任何帮助表示赞赏。询问更多信息。
最佳答案
如果您使用的是 expo,请确保您的 expo
和 react-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/