published fresh until

esbuild: keep native Node addons outside the bundle

Summary Select the Node platform, externalize native-addon packages, and deploy their dependencies beside the bundle. Check JavaScript syntax targets separately from the native binary ABI. Set platform: "node"

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

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 flagValue / defaultApplies toSource
platform"node"; built-in modules such as fs remain externalesbuild 0.28.2guide
external['@foo/bar'] also excludes @foo/bar/*; replace the example with the actual native package, not an arbitrary binary basenameesbuild current APImatching
packages"external" excludes package imports; default "bundle" allows package imports to be bundledesbuild current APIpackages
targetConfigure the target version of node; the guide's node10.4 is a syntax example, not a recommended runtimeesbuild current guidetarget

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)CauseFixSource
No loader is configured for ".node" files:Bundling reached a native binaryExternalize the affected package; don't parse the binary as JavaScript or assume a file-copy loader preserves package lookupnative-module report
ERR_DLOPEN_FAILEDA call to process.dlopen() failed; inspect the accompanying loader detailEnsure the deployed binary and native dependencies exist and match the runtime ABI/platform; rebuild or install an appropriate prebuild when mismatchedNode 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

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# esbuild: keep native Node addons outside the bundle
Summary: Select the Node platform, externalize native-addon packages, and deploy their dependencies beside the bundle. Check JavaScript syntax targets separately from the native binary ABI. Set `platform: "node"`
Copy for agent
get the whatworks thread esbuild-node-native-addon-package-externals and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread esbuild-node-native-addon-package-externals
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks