Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Can't require image with spaces, etc. in filename

已关闭
#1,609 2 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
42/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
javascript, react-native

调研方向

从 metro/src/Assets.js 中的 getAbsoluteAssetRecord 和 getAsset 开始,以报告的堆栈跟踪作为入口。在 React Native 0.81 下使用包含空格的文件名重现 asset 请求,并将行为与 0.79 进行比较。当 asset 能够加载,且 ENOENT 路径不包含文件名的编码字符时,即表示完成。

由索引模型根据 Issue 内容生成。

描述

Hi folks, I'm getting the same error seen in this very old RN issue:

https://github.com/facebook/react-native/issues/10364

Here is the stacktrace that shows this is ocurring in Assets.js

Error: ENOENT: no such file or directory, scandir '/Users/andrew/Work/Code/projects/Failure/Mobile/ReactNative/failure/.%2Fassets%2Fimages'
    at Object.readdir (node:internal/fs/promises:956:18)
    at getAbsoluteAssetRecord (/Users/andrew/Work/Code/projects/Failure/Mobile/ReactNative/failure/node_modules/@expo/metro/node_modules/metro/src/Assets.js:114:17)
    at getAsset (/Users/andrew/Work/Code/projects/Failure/Mobile/ReactNative/failure/node_modules/@expo/metro/node_modules/metro/src/Assets.js:224:18)
    at Server._processSingleAssetRequest (/Users/andrew/Work/Code/projects/Failure/Mobile/ReactNative/failure/node_modules/@expo/metro/node_modules/metro/src/Server.js:436:20)
    at Server._processRequest (/Users/andrew/Work/Code/projects/Failure/Mobile/ReactNative/failure/node_modules/@expo/metro/node_modules/metro/src/Server.js:535:7)

I've confirmed that the file name had a space in it; when I renamed it to not have a space, it works just fine. Strangely, this did not happen in 0.79 of React Native; I recently upgraded to 0.81 of RN, and this happened. Though it says it's expo related, when forking this repo, the node_module file for Assets.js was the same as here, so I assume it's the correct repo.

主要语言
JavaScript
星标
5.6k
派生
702
平均合并
2 天 20 小时
30 天内合并 PR
60

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

react/metro 的其他 Issue

查看 react/metro 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。