{"id":25303,"library":"esbuild-native-node-modules-plugin","title":"esbuild-native-node-modules-plugin","description":"A plugin for esbuild that enables bundling of native Node.js modules (.node files). Version 1.0.3 is current. It acts as a node-loader replacement for esbuild, allowing use of native addons in bundled output. Differentiates from general node-loader plugins by being esbuild-native and simple to integrate.","status":"active","version":"1.0.3","language":"javascript","source_language":"en","source_url":"https://github.com/ouxuwen/esbuild-native-node-modules-plugin","tags":["javascript","esbuild","plugin","native node modules","native node",".node","node addon","node-loader","typescript"],"install":[{"cmd":"npm install esbuild-native-node-modules-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add esbuild-native-node-modules-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add esbuild-native-node-modules-plugin","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM import is preferred if using modules.","wrong":"const nativeNodeModulesPlugin = require('esbuild-native-node-modules-plugin')","symbol":"nativeNodeModulesPlugin","correct":"import { nativeNodeModulesPlugin } from 'esbuild-native-node-modules-plugin'"},{"note":"CommonJS require with destructuring. No default export.","wrong":"const nativeNodeModulesPlugin = require('esbuild-native-node-modules-plugin').default","symbol":"nativeNodeModulesPlugin","correct":"const { nativeNodeModulesPlugin } = require('esbuild-native-node-modules-plugin')"},{"note":"Use named import, not default import.","wrong":"import nativeNodeModulesPlugin from 'esbuild-native-node-modules-plugin'","symbol":"nativeNodeModulesPlugin as nativeNodeModulesPlugin","correct":"import { nativeNodeModulesPlugin } from 'esbuild-native-node-modules-plugin'"}],"quickstart":{"code":"import { build } from 'esbuild';\nimport { nativeNodeModulesPlugin } from 'esbuild-native-node-modules-plugin';\n\nbuild({\n  entryPoints: ['src/index.ts'],\n  bundle: true,\n  outfile: 'dist/bundle.js',\n  platform: 'node',\n  plugins: [nativeNodeModulesPlugin],\n}).catch(() => process.exit(1));","lang":"typescript","description":"Shows using the plugin in an esbuild build to support native .node modules."},"warnings":[{"fix":"Set platform option in esbuild config to 'node'.","message":"Platform must be set to 'node' for native modules to work.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use import { nativeNodeModulesPlugin } from 'esbuild-native-node-modules-plugin'","cause":"Importing incorrectly as default export instead of named export.","error":"Error: The plugin \"nativeNodeModulesPlugin\" doesn't have a setup function"},{"fix":"Ensure plugin is added to esbuild config plugins array: plugins: [nativeNodeModulesPlugin]","cause":"Plugin is not properly registered in esbuild plugins array.","error":"TypeError: Cannot read properties of undefined (reading 'onResolve')"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}