Repository navigation
Description
Describe the Bug
Summary
Payload 3.85.1 upgraded its internal tsx dependency from 4.21.0 → 4.22.4. [email protected] added support for Node.js's new module.registerHooks() API (introduced in Node.js v23.5.0). On Node.js v23.5+, that new code path has a bug where built-in Node modules (like node:crypto) get a scoped namespace query string appended to their URL (node:crypto?tsx-namespace=1781028172599). Node.js then tries to open that string as a file path, which fails with ENOENT.
[email protected] (used by Payload 3.84.1 and 3.85.0) never used module.registerHooks — it always fell back to the older async module.register() path, which doesn't have this issue.
Root cause (technical)
pn payload migrate:create calls payload/bin.js, which runs:
// payload/bin.js
const { tsImport } = await import('tsx/esm/api')
const { bin } = await tsImport('./dist/bin/index.js', url)
tsImport in tsx/esm/api/index.mjs generates a unique namespace using Date.now() to scope module loading:
// tsx/dist/esm/api/index.mjs
const m = Date.now().toString() // e.g. "1781028172599"
const a = n({ namespace: m }) // registers hooks with this namespace
return p({ namespace: m }).import(r, o) // imports with same namespace
Inside n({ namespace: m }) (the register function), [email protected] checks:
// [email protected] only — this block doesn't exist in [email protected]
const useRegisterHooks =
typeof module.registerHooks === 'function' &&
isFeatureSupported(moduleRegisterHooksCjsReload) &&
!hasTypeScriptPreload
if (useRegisterHooks) {
// Uses module.registerHooks() — the synchronous, in-band hook API
module.registerHooks({ load: createLoadSync(state), resolve: createResolveSync(state) })
}
On Node.js v23.5+, module.registerHooks exists, so tsx uses the new synchronous hook path. These hooks run in-band (same thread, synchronously). During module loading, tsx adds ?tsx-namespace= to resolved file URLs so the scoped hooks know which modules to intercept.
The bug: somewhere in the registerHooks synchronous path, a Node.js built-in module URL (node:crypto) acquires the namespace query parameter (becoming node:crypto?tsx-namespace=1781028172599). The load hook then receives this URL, fails to recognise it as a built-in (the check is URL-prefix based and the query string confuses it), and passes it to the default loader — which tries to open() it as a file → ENOENT.
The older async module.register() path (used by [email protected] and [email protected] on Node.js < v23.5) runs the hooks in a separate worker thread, and this namespace-leaking-to-built-ins problem doesn't occur there.
Link to the code that reproduces this issue
github
Reproduction Steps
Steps to reproduce
Environment:
Node.js v23.5 or higher (confirmed on v25.8.2 and v26.3.0)
Payload 3.85.1 (or any Payload version that pulls [email protected])
1. Create a fresh Payload project
npx create-payload-app@latest my-app
cd my-app
2. Confirm tsx version is 4.22.4
cat node_modules/.pnpm/payload@*/node_modules/tsx/package.json | grep '"version"'
3. Confirm Node.js version is v23.5+
node --version
4. Run any migration command
pnpm payload migrate:create --name test
Expected: Migration file created in src/migrations/.
Actual:
Error: Error creating migration: ENOENT: no such file or directory,
open 'node:crypto?tsx-namespace=1781028172599'
at migrate (.../payload/src/bin/migrate.ts:110:15)
Workaround
Pin tsx to 4.21.0 via pnpm overrides in package.json:
"pnpm": {
"overrides": {
"tsx": "4.21.0"
}
}
Then pnpm install. The migration CLI works correctly because [email protected] doesn't use module.registerHooks and always falls back to the older async module.register() path.
Which area(s) are affected?
area: core
Environment Info
pn payload info
> [email protected] payload XX /projects/xxxxx
> cross-env NODE_OPTIONS=--no-deprecation payload info
Binaries:
Node: 26.3.0
npm: 11.16.0
Yarn: N/A
pnpm: 10.33.2
Relevant Packages:
payload: 3.85.1
next: 16.2.7
@payloadcms/db-postgres: 3.85.1
@payloadcms/drizzle: 3.81.0
@payloadcms/email-nodemailer: 3.85.1
@payloadcms/graphql: 3.81.0
@payloadcms/live-preview: 3.81.0
@payloadcms/live-preview-react: 3.85.1
@payloadcms/next/utilities: 3.85.1
@payloadcms/plugin-cloud-storage: 3.85.1
@payloadcms/plugin-form-builder: 3.85.1
@payloadcms/plugin-nested-docs: 3.85.1
@payloadcms/plugin-redirects: 3.85.1
@payloadcms/plugin-search: 3.85.1
@payloadcms/plugin-seo: 3.85.1
@payloadcms/richtext-lexical: 3.85.1
@payloadcms/storage-s3: 3.85.1
@payloadcms/translations: 3.81.0
@payloadcms/ui/shared: 3.85.1
react: 19.2.7
react-dom: 19.2.7
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 25.5.0: Mon Apr 27 20:39:42 PDT 2026; root:xnu-12377.121.6~2/RELEASE_ARM64_T6031
Available memory (MB): 36864
Available CPU cores: 14
Activity
github-actions commentedon Jun 9, 2026
Please add a reproduction in order for us to be able to investigate.
Depending on the quality of reproduction steps, this issue may be closed if no reproduction is provided.
Why was this issue marked with the
invalid-reproductionlabel?To be able to investigate, we need access to a reproduction to identify what triggered the issue. We prefer a link to a public GitHub repository created with
create-payload-app@latest -t blankor a forked/branched version of this repository with tests added (more info in the reproduction-guide).To make sure the issue is resolved as quickly as possible, please make sure that the reproduction is as minimal as possible. This means that you should remove unnecessary code, files, and dependencies that do not contribute to the issue. Ensure your reproduction does not depend on secrets, 3rd party registries, private dependencies, or any other data that cannot be made public. Avoid a reproduction including a whole monorepo (unless relevant to the issue). The easier it is to reproduce the issue, the quicker we can help.
Please test your reproduction against the latest version of Payload to make sure your issue has not already been fixed.
I added a link, why was it still marked?
Ensure the link is pointing to a codebase that is accessible (e.g. not a private repository). "example.com", "n/a", "will add later", etc. are not acceptable links -- we need to see a public codebase. See the above section for accepted links.
Useful Resources
royalswe commentedon Jun 9, 2026
I got the same issue with latest payload version 3.85.1
Im on a Apple M1 Pro (Tahoe 26.5.1)
Node 24.16.0 and 26.0.0
VivienInteractive commentedon Jun 10, 2026
Hello, Same for me payload version 3.85.1 and node 24.13.1
aufdenpunkt commentedon Jun 10, 2026
Hi, same for me.
Payload version: 3.85.1
Node version: 24.16.0
smoothdvd commentedon Jun 10, 2026
Claude fixed it with following:
rgbjoy commentedon Jun 13, 2026
Same error
node v26.3.0
payload 3.85.1
build(packaging): downgrade payload cms from 3.85.1 to 3.85.0
oxidia commentedon Jun 16, 2026
Same issue
payload version:
3.85.1node version:
24.15.0JorenRothman commentedon Jun 18, 2026
Found a temporary fix for this issue (payload 3.85.1)
Add this to your package overrides:
'tsx': '4.19.4'
for example pnpm-workspace.yaml
Vovcharaa commentedon Jun 19, 2026
Same here with:
payload: 3.85.1
tsx: 4.22.4
node: v24.16.0
Codex did this import before running payload to mitigate issue:
jliguori1312 commentedon Jun 21, 2026
Same issue here, payload 3.85.1, tsx 4.22.4 and node 24.14.1.
estevan-ulian commentedon Jun 22, 2026
That temporary solution worked for me:
node_modulespnpm-workspace.yaml:pnpm installpnpm migrate:create 'message'pnpm migrateMy scripts:
My project info:
Binaries: Node: 24.15.0 npm: 11.12.1 Yarn: N/A pnpm: 11.0.9 Relevant Packages: payload: 3.85.1 next: 16.2.9 @payloadcms/db-postgres: 3.85.1 @payloadcms/drizzle: 3.85.1 @payloadcms/email-nodemailer: 3.85.1 @payloadcms/graphql: 3.85.1 @payloadcms/next/utilities: 3.85.1 @payloadcms/plugin-cloud-storage: 3.85.1 @payloadcms/plugin-seo: 3.85.1 @payloadcms/richtext-lexical: 3.85.1 @payloadcms/storage-s3: 3.85.1 @payloadcms/translations: 3.85.1 @payloadcms/ui/shared: 3.85.1 react: 19.2.7 react-dom: 19.2.7 Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 25.5.0: Mon Apr 27 20:40:51 PDT 2026; root:xnu-12377.121.6~2/RELEASE_ARM64_T8112 Available memory (MB): 16384 Available CPU cores: 8fix: payload bin fails with tsx on node v23.5+ (#17079)
feat(fonts): build fonts straight from the database — no running site…
build: compose produksi dengan volume upload dan migrasi gagal-keras
Pin Node 22.23.2 and tsx 4.21.0 for Payload's CLI tooling
fix(richtext-lexical)!: upgrade lexical to 0.52.0 and tsx to 4.23.15 (#…
fix: prevent silent CLI exits (#18398)