【发布时间】:2021-06-22 16:44:57
【问题描述】:
【问题讨论】:
标签: android react-native gradle build react-native-android
【问题讨论】:
标签: android react-native gradle build react-native-android
这个问题似乎是由于浏览器(我的情况是 Chrome)请求的 Metro bundler 和源地图,我已经列出了解决这个问题的以下步骤。
注意:
下面提到的补丁脚本只和metro@0.64.0有关。如果您有其他版本,可以尝试修改脚本或在 GitHub 问题中搜索 metro 以查找与您的版本相关的内容。
yarn add patch-package 安装patch-package。package.json 文件并将这一行添加到scripts 中:"postinstall": "patch-package"
mkdir patches 在您项目的根目录中(如果您还没有的话)。patches/metro+0.64.0.patch:diff --git a/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js b/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js
index 5f32fc5..2b80fda 100644
--- a/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js
+++ b/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js
@@ -346,7 +346,7 @@ class UnableToResolveError extends Error {
try {
file = fs.readFileSync(this.originModulePath, "utf8");
} catch (error) {
- if (error.code === "ENOENT") {
+ if (error.code === "ENOENT" || error.code === 'EISDIR') {
// We're probably dealing with a virtualised file system where
// `this.originModulePath` doesn't actually exist on disk.
// We can't show a code frame, but there's no need to let this I/O
运行yarn postinstall,它应该修补metro@0.64.0。
在 Chrome 开发工具中,取消选中:
运行react-native start,您应该一切顺利。
参考:GitHub => react-native-fs => Issue 991
【讨论】: