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

Reliance on `require(esm)` in the `react-native-node-api-modules` package may cause onboarding frictions

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

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
58/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
node.js, react-native, typescript
Lĩnh vực
build-system, cli, mobile

Hướng nghiên cứu

Bắt đầu với packages/react-native-node-api-modules/src/node/cli/program.ts và packages/react-native-node-api-modules/tsconfig.node.json, sau đó tái hiện pod install bằng Node.js v22.11.0. Kiểm tra dist/node/cli/program.js được tạo ra và xác nhận rằng luồng patching của Hermes hoàn tất mà không có lỗi require(esm); issue không nêu tên tệp kiểm thử nào.

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

Mô tả

good first issue

Background

I ran into a problem with require(esm) when attempting to run pod install on a React Native iOS (Expo) app that depends on react-native-node-api-modules. It seems that although I'm running an LTS version of Node, only the more recent minor releases actually support that feature.

require(esm) is supported (without --experimental-require-module) from Node.js v22.12.0+ and v23.0.0+. Although v22 is in Active LTS, versions below 22.12.0 lack this feature, and although v22.13.0 has been available for half a year already, having come out in December 2024, there's a fair chance that users won't have it installed yet. I happened to be on Node.js v22.11.0, for example 😅

We might reduce onboarding frictions by avoiding require(esm) here.

Issue

The file packages/react-native-node-api-modules/src/node/cli/program.ts writes this ESM import in TypeScript:

import { SpawnFailure } from "bufout";

Based on the config in packages/react-native-node-api-modules/tsconfig.node.json, this gets transpiled to CommonJS in packages/react-native-node-api-modules/dist/node/cli/program.js:

const bufout_1 = require("bufout");
// ... which later is accessed as `bufout_1.SpawnFailure`

This leads to the following error upon running cd ios && pod install in the latest Expo template when Node v22.11.0 is on the shell's PATH.

[Expo] Enabling modular headers for pod React-hermes
/Users/jamie/Documents/git/react-native-node-api-modules/packages/react-native-node-api-modules/dist/node/cli/program.js:315
undefined
             ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/jamie/Documents/git/react-native-node-api-modules/node_modules/bufout/dist/index.js from /Users/jamie/Documents/git/react-native-node-api-modules/packages/react-native-node-api-modules/dist/node/cli/program.js not supported.
Instead change the require of index.js in /Users/jamie/Documents/git/react-native-node-api-modules/packages/react-native-node-api-modules/dist/node/cli/program.js to a dynamic import() which is available in all CommonJS modules.
    at TracingChannel.traceSync (node:diagnostics_channel:315:14)
    at Object.<anonymous> (/Users/jamie/Documents/git/react-native-node-api-modules/packages/react-native-node-api-modules/dist/node/cli/program.js:11:18) {
  code: 'ERR_REQUIRE_ESM'
}

Node.js v22.11.0

[!] Invalid `Podfile` file: 
[!] Invalid `react-native-node-api-modules.podspec` file: Hermes patching failed. Please check the output above for errors..

 #  from /Users/jamie/Documents/git/react-native-node-api-modules/node_modules/react-native-node-api-modules/react-native-node-api-modules.podspec:5
 #  -------------------------------------------
 #  
 >  require_relative "./scripts/patch-hermes"
 #  
 #  -------------------------------------------
.

 #  from /Users/jamie/Documents/git/react-native-node-api-modules/apps/expo-template/ios/Podfile:32
 #  -------------------------------------------
 #  
 >    config = use_native_modules!(config_command)
 #  
 #  -------------------------------------------

[!] !!! PATCHING HERMES WITH NODE-API SUPPORT !!!

In one screenshot:

Image
Ngôn ngữ chính
TypeScript
Star
188
Fork
10
Merge trung bình
2 ngày 17 giờ
Pull request đã merge (30 ngày)
3

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

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 callstackincubator/react-native-node-api

Tất cả issue của callstackincubator/react-native-node-api

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.