{{ message }}
fix(next): use namespace import for @next/env to fix Node 24 ESM compat#16342
Open
micahshu wants to merge 1 commit intopayloadcms:mainfrom
Open
fix(next): use namespace import for @next/env to fix Node 24 ESM compat#16342micahshu wants to merge 1 commit intopayloadcms:mainfrom
micahshu wants to merge 1 commit intopayloadcms:mainfrom
Conversation
…ompat Node 24 strictly follows the __esModule flag on CJS modules and returns undefined for default imports when no .default property exists. @next/env is a CJS-only bundle that sets __esModule: true but has no default export, causing `payload run` to crash immediately on Node 24. Switching to a namespace import with a fallback resolves the crash on Node 24 while remaining compatible with older Node versions (18/20). Fixes payloadcms#16341
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

What
Fixes
payload runcrashing immediately on Node.js 24 with:Why
@next/envis a CJS-only bundle that sets__esModule: trueonmodule.exportsbut has no.defaultproperty. Node 24strictly follows the
__esModuleflag and returnsundefinedfor default imports. Older Node versions (18/20) fall back tothe whole
module.exportsobject, which is why this only surfaces on Node 24.Named imports also fail — the CJS bundle is not statically analyzable so Node 24 cannot detect its named exports. The namespace
import (
import * as) is the only form that works across all Node versions.How