Acknowledgements
Minimal reproduction URL
https://github.com/ryanbonial/tsx-pkg-utils-node24-repro
Problem & expected behavior (under 200 words)
What happened: tsImport() throws ERR_MODULE_NOT_FOUND on Node 24 when a CommonJS-context .ts file imports a dependency from an ESM package. Works on Node 22.
What I expected: Same behavior on Node 24 as Node 22 (load succeeds).
Matrix with tsx@4.22.3: Node 22.13.1 ✓, 22.18.0 ✓, 24.12.0 ✗, 24.15.0 ✗.
Stack trace:
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '.../esm-fixture/dist/index.js?namespace=1779473031813' imported from .../config/package.config.ts?namespace=1779473031813
at finalizeResolution (node:internal/modules/esm/resolve:274:11)
at moduleResolve (node:internal/modules/esm/resolve:864:10)
at defaultResolve (node:internal/modules/esm/resolve:990:11)
at #cachedDefaultResolve (node:internal/modules/esm/loader:718:20)
at #resolveAndMaybeBlockOnLoaderThread (node:internal/modules/esm/loader:735:38)
at nextStep (node:internal/modules/customization_hooks:189:26)
at resolveBaseSync (.../tsx/dist/register-D_B8UL5H.mjs:2:8642)
at resolveDirectorySync (.../tsx/dist/register-D_B8UL5H.mjs:2:9781)
at resolveTsPathsSync (.../tsx/dist/register-D_B8UL5H.mjs:2:11014)
at resolve2 (.../tsx/dist/register-D_B8UL5H.mjs:2:12901) {
code: 'ERR_MODULE_NOT_FOUND',
url: 'file:///.../esm-fixture/dist/index.js%3Fnamespace=1779473031813'
}
The repro mirrors @sanity/pkg-utils's loadConfig(): tsImport(pathToFileURL(configFile).toString(), import.meta.url) where configFile is a CJS-context package.config.ts doing import { defineConfig } from '@sanity/pkg-utils'.
Bugs are expected to be fixed by those affected by it
Compensating engineering work will speed up resolution and support the project
Acknowledgements
Minimal reproduction URL
https://github.com/ryanbonial/tsx-pkg-utils-node24-repro
Problem & expected behavior (under 200 words)
What happened:
tsImport()throwsERR_MODULE_NOT_FOUNDon Node 24 when a CommonJS-context.tsfile imports a dependency from an ESM package. Works on Node 22.What I expected: Same behavior on Node 24 as Node 22 (load succeeds).
Matrix with
tsx@4.22.3: Node 22.13.1 ✓, 22.18.0 ✓, 24.12.0 ✗, 24.15.0 ✗.Stack trace:
The repro mirrors
@sanity/pkg-utils'sloadConfig():tsImport(pathToFileURL(configFile).toString(), import.meta.url)whereconfigFileis a CJS-contextpackage.config.tsdoingimport { defineConfig } from '@sanity/pkg-utils'.Bugs are expected to be fixed by those affected by it
Compensating engineering work will speed up resolution and support the project