Skip to content

Conversation

@lizkenyon
Copy link
Contributor

@lizkenyon lizkenyon commented Oct 30, 2025

Fix ERR_REQUIRE_ESM errors that occur inconsistently across different Node.js and npm version
combinations when running this app.

The @react-router/dev v7.x dependency chain pulls in p-map@^7.0.3, which is ESM-only. The compiled @react-router/dev code uses require(p-map) in its vite.js file. While Node.js v22.12.0+ and v20.19.0+ support require(esm) by default, some users still encounter ERR_REQUIRE_ESM errors even on Node v23.10.0 with npm 11.6.2. The exact conditions causing the error are not fully understood, but forcing p-map@^4.0.0 (CommonJS-compatible) resolves it across all reported cases. This is safe because @react-router/dev only uses basic p-map features (array mapping + concurrency option) that exist in both v4 and v7.

WHY are these changes introduced?

Fixes #0000

WHAT is this pull request doing?

Test this PR

shopify app init --template=https://github.com/Shopify/shopify-app-template-react-router#add-pmap-override

Checklist

  • I have made changes to the README.md file and other related documentation, if applicable
  • I have added an entry to CHANGELOG.md
  • I'm aware I need to create a new release when this PR is merged
@lizkenyon lizkenyon requested a review from a team as a code owner October 30, 2025 17:14
Fix ERR_REQUIRE_ESM errors that occur inconsistently across different Node.js and npm version combinations when running this app. The @react-router/dev v7.x dependency chain pulls in p-map@^7.0.3, which is ESM-only. The compiled @react-router/dev code uses require(p-map) in its vite.js file. While Node.js v22.12.0+ and v20.19.0+ support require(esm) by default, some users still encounter ERR_REQUIRE_ESM errors even on Node v23.10.0 with npm 11.6.2. The exact conditions causing the error are not fully understood, but forcing p-map@^4.0.0 (CommonJS-compatible) resolves it across all reported cases. This is safe because @react-router/dev only uses basic p-map features (array mapping + concurrency option) that exist in both v4 and v7.
@lizkenyon lizkenyon merged commit fc72b88 into main Oct 31, 2025
19 checks passed
github-actions bot pushed a commit that referenced this pull request Oct 31, 2025
[Fix] Add p-map override to fix ERR_REQUIRE_ESM errors in some environments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants