What version of pkg are you using?
@yao-pkg/pkg@6.20.0
What version of Node.js are you using?
v25.6.0
What operating system are you using?
macOS, Apple Silicon
What CPU architecture are you using?
Apple M4
What Node versions, OSs and CPU architectures are you building for?
node22-macos-arm64
Describe the Bug
A packaged ESM app crashes at startup when it imports a package whose exports map is valid for ESM import but not resolvable through CommonJS require().
Plain Node runs the app correctly. The packaged binary builds successfully, but crashes at runtime.
I created a minimal repro repo here:
https://github.com/JustasMonkev/pkg-esm-runtime-repro
There are two related cases in the repro:
- ESM-only package with only an
import condition:
{
"exports": {
".": {
"import": "./index.mjs"
}
}
}
### Expected Behavior
Not to crash
### To Reproduce
git clone https://github.com/JustasMonkev/pkg-esm-runtime-repro.git
cd pkg-esm-runtime-repro
npm install
npm run check
npm run e2e
What version of pkg are you using?
@yao-pkg/pkg@6.20.0
What version of Node.js are you using?
v25.6.0
What operating system are you using?
macOS, Apple Silicon
What CPU architecture are you using?
Apple M4
What Node versions, OSs and CPU architectures are you building for?
node22-macos-arm64
Describe the Bug
A packaged ESM app crashes at startup when it imports a package whose
exportsmap is valid for ESM import but not resolvable through CommonJSrequire().Plain Node runs the app correctly. The packaged binary builds successfully, but crashes at runtime.
I created a minimal repro repo here:
https://github.com/JustasMonkev/pkg-esm-runtime-repro
There are two related cases in the repro:
importcondition:{ "exports": { ".": { "import": "./index.mjs" } } } ### Expected Behavior Not to crash ### To Reproduce git clone https://github.com/JustasMonkev/pkg-esm-runtime-repro.git cd pkg-esm-runtime-repro npm install npm run check npm run e2e