Registry / type-stubs / is-bun-module

is-bun-module

JSON →
library2.0.0jsnpmunverified

is-bun-module is a TypeScript utility library designed to programmatically identify and list modules within the Bun runtime environment. It distinguishes between Bun's native core modules (e.g., `bun:test`) and Node.js built-in modules that Bun has implemented (e.g., `fs`, `path`). The library provides functions to check individual module specifiers as well as retrieve comprehensive lists of all supported modules, optionally filtered by a specific Bun version string (e.g., '1.0.0' or 'latest'). As of version 2.0.0, the package is actively maintained with regular updates to reflect changes in Bun's module landscape, and it ships with full TypeScript type definitions for robust development.

npm install is-bun-module
INSTALL
IMPORT
SIG · IS-BUN-MODULE
I
is-bun-module
type-stubsjavascriptv2.0.0
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 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

isBunModule
import { isBunModule } from 'is-bun-module';
const isBunModule = require('is-bun-module').isBunModule;
Primary function for checking Bun-specific modules. This package is primarily ESM.
isBunImplementedNodeModule
import { isBunImplementedNodeModule } from 'is-bun-module';
import { isSupportedNodeModule } from 'is-bun-module';
Checks for Node.js modules implemented by Bun. Renamed from `isSupportedNodeModule` in v2.0.0.
getBunBuiltinModules
import { getBunBuiltinModules } from 'is-bun-module';
const getBunBuiltinModules = require('is-bun-module').getBunBuiltinModules;
Retrieves a combined list of all Bun and Bun-implemented Node.js modules.
BunVersion
import type { BunVersion } from 'is-bun-module';
import type { Version } from 'is-bun-module';
Type definition for Bun version specifiers. Renamed from `Version` to `BunVersion` in v2.0.0.

Demonstrates how to use `isBunModule`, `isBunImplementedNodeModule`, and `getBunBuiltinModules` to identify and list modules, including specifying Bun versions.

import { isBunModule, isBunImplementedNodeModule, getBunBuiltinModules, BunVersion } from 'is-bun-module'; // Check specific Bun modules console.log('Is "bun" a Bun module?', isBunModule('bun')); console.log('Is "bun:test" a Bun module (Bun v1.0.0)?', isBunModule('bun:test', '1.0.0' as BunVersion)); console.log('Is "notBunModule" a Bun module?', isBunModule('notBunModule')); // Check Node.js modules implemented in Bun console.log('Is "fs" a Bun-implemented Node module?', isBunImplementedNodeModule('fs')); console.log('Is "node:http2" a Bun-implemented Node module (Bun v1.0.0)?', isBunImplementedNodeModule('node:http2', '1.0.0' as BunVersion)); // Get a list of all builtin modules for the latest Bun version const latestBuiltins = getBunBuiltinModules('latest'); console.log('First 5 builtin modules (latest Bun):', latestBuiltins.slice(0, 5)); // Example with an older Bun version const bunV1_0_0Builtins = getBunBuiltinModules('1.0.0' as BunVersion); console.log('Number of builtin modules in Bun v1.0.0:', bunV1_0_0Builtins.length); // Type assertion for clarity when passing string literals as BunVersion const currentBunVersion: BunVersion = '1.0.13'; console.log(`Checking 'crypto' against Bun ${currentBunVersion}:`, isBunImplementedNodeModule('crypto', currentBunVersion));
Debug
Known issues
breakingThe function `isSupportedNodeModule` was renamed to `isBunImplementedNodeModule`.
fix
Update all calls from `isSupportedNodeModule` to `isBunImplementedNodeModule`.
affects: >=2.0.0
breakingThe TypeScript type `Version` was renamed to `BunVersion` to avoid naming conflicts and improve clarity.
fix
Change all type references from `Version` to `BunVersion`.
affects: >=2.0.0
gotchaThis library explicitly supports Bun v1.0.0 and newer. Using it with older Bun versions or expecting support for modules not yet implemented in v1.0.0+ may lead to unexpected results.
fix
Ensure your Bun environment is at least v1.0.0. When querying for module support, pass the exact `bunVersion` string matching your target Bun runtime for accurate results.
affects: >=1.0.0
gotchaThe `bunVersion` parameter accepts semantic version strings (e.g., '1.0.0', '1.0.13') or the literal string 'latest'. Providing an invalid format will result in unpredictable behavior.
fix
Always pass a valid semantic version string or 'latest' to the `bunVersion` parameter.
affects: >=1.2.0
Errors
Common errors & fixes
TypeError: isSupportedNodeModule is not a function
Attempting to use the old function name `isSupportedNodeModule` after upgrading to v2.0.0 or higher.
fix
Rename `isSupportedNodeModule` to `isBunImplementedNodeModule`.
ReferenceError: require is not defined
This package is distributed as an ES Module (ESM). Using CommonJS `require()` syntax in an ESM context (e.g., a `.js` file with `"type": "module"` or a `.mjs` file) will fail.
fix
Use ES module import syntax: `import { functionName } from 'is-bun-module';`.
TypeError: Module 'is-bun-module' has no exported member 'Version'
Attempting to import the `Version` type after upgrading to v2.0.0 or higher.
fix
Update the type import from `import type { Version }` to `import type { BunVersion }`.
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
28 hits · last 30 days
node
25
OpenAI (training)
1
Resources
is-bun-module — npm install is-bun-module · libregistry