Registry / devops / rollup-plugin-native

rollup-plugin-native

JSON →
library1.2.16jsnpmunverified

A Rollup plugin that enables importing native .node modules (N-API addons) by resolving platform-specific binary paths during bundling. Version 1.2.16, last updated in 2024, with low release cadence (no breaking changes in recent versions). It uses substitution patterns like ${nodePlatform} and ${nativeArchitecture} to dynamically select the correct precompiled binary for the current OS/arch, avoiding the need for node-gyp at runtime. Differentiators: simplifies cross-platform native module bundling without manual conditional requires, and integrates directly into Rollup's plugin system. No other known alternative for Rollup-focused native module import.

npm install rollup-plugin-native
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-NATI
R
rollup-plugin-native
devopsjavascriptv1.2.16
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default (native)
import native from 'rollup-plugin-native'
const native = require('rollup-plugin-native')
ESM-only package; CommonJS require() will work but is not recommended for Rollup configs.
native
import native from 'rollup-plugin-native'
import { native } from 'rollup-plugin-native'
The plugin exports a default function, not a named export. Use default import.
RollupPluginNativeOptions
/** @type {import('rollup-plugin-native').PluginOptions} */
undefined
TypeScript types may not be shipped; use JSDoc or custom type definitions.

Configures Rollup to resolve native .node modules with platform-specific binary paths using substitution variables.

// rollup.config.js import native from 'rollup-plugin-native'; export default { input: 'src/index.js', output: { dir: 'dist', format: 'cjs' }, plugins: [ native({ platformName: 'precompiled/${nodePlatform}-${nodeArchitecture}/native.node' }) ] };
Debug
Known issues
gotchaFormat 'cfs' in documentation is a typo; use 'cjs' for CommonJS output.
fix
Use output.format: 'cjs' instead of 'cfs'.
affects: all
gotchaDynamic require of .node files may not work in all Rollup output formats (e.g., esm).
fix
Ensure output format is 'cjs' when using native modules, or use plugin options to generate conditional require.
affects: all
deprecatedSubstitution ${basename} strips .node extension; ensure paths are correct.
fix
Use ${basename} without .node in the path template, as the extension is handled internally.
affects: >=1.0.0
breakingThe plugin only supports Rollup >=3.0.0; older versions may fail.
fix
Upgrade Rollup to version 3 or later.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module '../module.node'
platformName pattern does not match the actual file path
fix
Verify platformName template resolves correctly; check process.platform() and process.arch() values.
TypeError: native is not a function
Named import used instead of default import
fix
Use default import: import native from 'rollup-plugin-native'
(!) Plugin native: Options object is required
Plugin instantiated without options but platformName is required
fix
Pass an options object with a 'platformName' property to native().
Error: Rollup plugin native requires Rollup >=3.0.0
Using an older version of Rollup
fix
Upgrade Rollup to 3.x or later: npm install rollup@latest --save-dev
Upgrade
Version history
1.2.16latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
7 hits · last 30 days
node
6
OpenAI (training)
1
Resources
rollup-plugin-native — npm install rollup-plugin-native · libregistry