What this thread does
Do first: set esbuild platform: "node" and keep the native addon's package external before bundling a Node application.
Short answer
As of November 2026, esbuild 0.28.2 is the current release (release). Native .node modules are a documented bundling limitation; Node built-ins such as fs are marked external but does not turn native binaries into JavaScript (Node bundling).
Choose / don't choose
- Narrow
external: choose when bundling ordinary dependencies but preserving a native package's own runtime loading/layout. A package entry also excludes its subpaths (external matching). packages: "external": choose when deploying all dependencies alongside the bundle; don't expect a standalone output file. Keep dependency files available at runtime (Node bundling).
Not for: choosing an application bundler; see vite-8-esbuild-turbopack-webpack-or-tsdown-for-js-builds-2026.
Settings that matter
| Setting or flag | Value / default | Applies to | Source |
|---|---|---|---|
platform | "node"; built-in modules such as fs remain external | esbuild 0.28.2 | guide |
external | ['@foo/bar'] also excludes @foo/bar/*; replace the example with the actual native package, not an arbitrary binary basename | esbuild current API | matching |
packages | "external" excludes package imports; default "bundle" allows package imports to be bundled | esbuild current API | packages |
target | Configure the target version of node; the guide's node10.4 is a syntax example, not a recommended runtime | esbuild current guide | target |
Order of operations
1. Identify the native package owning the .node import. Externalize its package so its wrapper and binary lookup retain their expected relationship (native-module discussion). 2. Configure the Node platform and target version of node. Install/package the external dependencies and their compatible binaries for the destination platform; preserving an import does not provide its runtime files (guide). 3. In the deployed runtime inspect process.versions.modules for the module ABI. A binary built for a different ABI is refused. For addons using Node-API exclusively, consult the Node-API version matrix; also check the addon's external native libraries (process, Node-API matrix/stability). 4. Exercise the native package from the final artifact on the destination runtime. The syntax target does not compile a native addon or grant ABI compatibility; those are separate checks inferred from the two toolchains' documented responsibilities.
Known failures and fixes
| Error (short quote) | Cause | Fix | Source |
|---|---|---|---|
No loader is configured for ".node" files: | Bundling reached a native binary | Externalize the affected package; don't parse the binary as JavaScript or assume a file-copy loader preserves package lookup | native-module report |
ERR_DLOPEN_FAILED | A call to process.dlopen() failed; inspect the accompanying loader detail | Ensure the deployed binary and native dependencies exist and match the runtime ABI/platform; rebuild or install an appropriate prebuild when mismatched | Node error, ABI |
The March 25, 2021 native-module discussion records the package-layout problem. Node-API provides an ABI stability guarantee, while other parts of Node.js do not and does not guarantee an addon's external library compatibility (Node-API).
Missing
- No package-specific ABI/prebuild matrix is established without the actual addon name, operating system and CPU architecture.
Checked
2026-11-12; esbuild 0.28.2 release, current esbuild guide/API, native-module issue, current Node process/error/Node-API references read. No bundle or addon executed.
Started from a post by @Evan Wallace, packaged by the editor. Original post