Error when using with metro only
维护者通常 3 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 40/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 冷清
- 技术栈
- javascript, react-native
- 领域
- build-system, tooling
调研方向
Start with the metro.config.js from the linked example repository and reproduce the 'Cannot find module expo/package.json' error by running npm run start. The stack trace points to node_modules/@expo/metro-config/build/transform-worker/utils/moduleMapper.js, so read how that file resolves modules and why it needs expo/package.json. Done means Metro loads a config built from @expo/metro-config without installing the full expo package, or the README is corrected to say otherwise.
由索引模型根据 Issue 内容生成。
描述
Before submitting a new issue
- I tested using the latest version of the library, as the bug might be already fixed.
- I tested using a supported version of react native.
- I checked for possible duplicate issues, with possible answers.
Bug summary
The instructions in the README.md state:
Non-Expo Projects
react-native-css relies on the bundler to process CSS files. Currently only Expo provides a CSS asset pipeline. Since the Expo SDK is modular, you can add this functionality by just using the @expo/metro-config package.
Follow the Expo instructions, but replace the expo package with @expo/metro-config.
When I try this I receive an error:
error Error loading Metro config at: metro.config.js
Cannot find module 'expo/package.json'
Require stack:
- node_modules/@expo/metro-config/build/transform-worker/utils/moduleMapper.js
Is there a specific version of @expo/metro-config I should be using? I'd like to avoid importing all of expo.
Library version
3.0.7
Environment info
System:
OS: Linux 7.0
CPU:
Memory: GB
Shell:
version: 5
path: /bin/sh
Binaries:
Node:
version: 24.15.0
path:
Yarn:
version: 1.22.22
path:
npm:
version: 11.13.0
path:
Watchman: Not Found
SDKs:
Android SDK: Not Found
IDEs:
Android Studio: Not Found
Languages:
Java:
version: 17.0.19
path:
Ruby: Not Found
npmPackages:
"@react-native-community/cli":
installed: 20.1.3
wanted: ^20.1.3
react:
installed: 19.2.3
wanted: ^19.2.5
react-native:
installed: 0.85.3
wanted: ^0.85.3
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: true
newArchEnabled: true
iOS:
hermesEnabled: true
newArchEnabled: true
Steps to reproduce
npx @react-native-community/cli@latest init reactNativeCssExample --version latestnpm i --save-dev react-native-css @expo/metro-config- setup
metro.config.js
const { mergeConfig } = require('@react-native/metro-config');
const { getDefaultConfig } = require('@expo/metro-config');
/**
* Metro configuration
* https://reactnative.dev/docs/metro
*
* @type {import('@react-native/metro-config').MetroConfig}
*/
const config = {};
module.exports = mergeConfig(
getDefaultConfig(__dirname),
config
);
npm run start
Reproducible example repository
- 主要语言
- TypeScript
- 星标
- 166
- 派生
- 45
- 平均合并
- 13 天 14 小时
- 30 天内合并 PR
- 1
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
nativewind/react-native-css 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
nativewind/react-native-css#545 ·
维护者通常 3 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
nativewind/react-native-css#544 ·
维护者通常 3 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
nativewind/react-native-css#543 ·
维护者通常 3 天内回复
-
难度 2/5 1-3 小时 新手友好度 84/100
nativewind/react-native-css#540 ·
维护者通常 3 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
nativewind/react-native-css#538 ·
维护者通常 3 天内回复
查看 nativewind/react-native-css 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 66/100
CopilotKit/openmuse#215 ·
维护者通常 3 天内回复
-
b:minor bug
难度 2/5 1-3 小时 新手友好度 76/100
software-mansion/argent#1698 ·
维护者通常 1 天内回复
-
e2e-failure ready-to-code
难度 2/5 1-3 小时 新手友好度 72/100
redhat-developer/rhdh-plugin-export-overlays#4624 · 1 条评论 ·
维护者通常 1 天内回复