Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Error when using with metro only

Đang mở
#338 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 3 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
40/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
javascript, react-native
Lĩnh vực
build-system, tooling

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

auto-triaged bug deferred (post-5.0) needs-deep-triage
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
  1. npx @react-native-community/cli@latest init reactNativeCssExample --version latest
  2. npm i --save-dev react-native-css @expo/metro-config
  3. 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
);
  1. npm run start
Reproducible example repository

https://github.com/wallzero/react-native-css-example

Ngôn ngữ chính
TypeScript
Star
166
Fork
45
Merge trung bình
13 ngày 14 giờ
Pull request đã merge (30 ngày)
1

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của nativewind/react-native-css

Tất cả issue của nativewind/react-native-css

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.