Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

オープン
#110 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
58/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
node.js, react-native, typescript

調査の方向性

packages/react-native-node-api-modules/src/node/cli/program.ts と packages/react-native-node-api-modules/tsconfig.node.json から始め、Node.js v22.11.0 で pod install を再現します。生成された dist/node/cli/program.js を確認し、Hermes のパッチ適用フローが require(esm) エラーなしで完了することを確認してください。この issue ではテストファイルは指定されていません。

索引モデルが issue の本文から書いたものです。

説明

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
主要言語
TypeScript
スター
188
フォーク
10
平均マージ
2日 17時間
マージ済み PR(30日)
3

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

callstackincubator/react-native-node-api のほかの issue

callstackincubator/react-native-node-api の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。