motayeb/node_modules/is-core-module/README.md
Kazem Alghasi c16648678d - install local Tailwind
- fix more problems
2026-09-23 00:32:16 +03:30

2.6 KiB

is-core-module Version Badge

github actions coverage dependency status dev dependency status License Downloads

npm badge

Is this specifier a node.js core module? Optionally provide a node version to check; defaults to the current node version.

Example

var isCore = require('is-core-module');
var assert = require('assert');
assert(isCore('fs'));
assert(!isCore('butts'));

TypeScript

isCore accepts any string. isCore.Module is the union of every specifier in core.json, regardless of node version, so editors can suggest them.

The types import core.json, so resolveJsonModule, esModuleInterop, and allowSyntheticDefaultImports must be enabled; some module and moduleResolution settings enable them by default, but node16 does not enable resolveJsonModule. Without them, TypeScript reports an error in this package's index.d.ts, or, with skipLibCheck, isCore.Module silently widens to string | number | symbol.

import isCore = require('is-core-module');

function isBuiltin(specifier: string): boolean {
	return isCore(specifier); // any string is accepted
}

const name: isCore.Module = 'node:fs'; // only specifiers listed in `core.json`
isCore(name, '16.0.0'); // true

Tests

Clone the repo, npm install, and run npm test