【发布时间】: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 架构支持)
- 我已经尝试了错误中提到的步骤。
- 我尝试多次删除
/node_modules和npm install。 - 在
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