canirequire

canirequire › Dual (CommonJS + ESM) › pure-rand

Is pure-rand ESM-only? Can you require() it?

Pure random number generator written in TypeScript

Last verified Sep 9, 2026 against pure-rand@8.4.2. Markdown · JSON

Dual (CommonJS + ESM) Dual package, subpaths only — require("pure-rand/…") works, require("pure-rand") does not

pure-rand exposes only subpaths in its exports map, for example "pure-rand/utils/skipN"; there is no root entry, so require("pure-rand") and import "pure-rand" both throw ERR_PACKAGE_PATH_NOT_EXPORTED. Each subpath ships a CommonJS and a native ESM build, so require("pure-rand/utils/skipN") and import "pure-rand/utils/skipN" both work.

What to do

  1. Load subpaths, never the bare name: const pureRand = require("pure-rand/utils/skipN") or import from "pure-rand/utils/skipN". require("pure-rand") throws ERR_PACKAGE_PATH_NOT_EXPORTED.
  2. TypeScript: no types are available for pure-rand; declare the module yourself if you need them.
Latest
8.4.2 (Jul 10, 2026)
Module format
Dual (CommonJS + ESM)
Last CommonJS version
8.4.2
Native ESM since
4.1.2
TypeScript types
None
Node engines
not declared
Weekly downloads
50.9M
License
MIT

Does pure-rand@8.4.2 actually load? Runtime test results

Installed and executed on Sep 9, 2026 with require("pure-rand") from a CommonJS file and import "pure-rand" from an ES module.

Runtimerequire("pure-rand")import "pure-rand"
Node.js 18✗ failsERR_PACKAGE_PATH_NOT_EXPORTED✗ failsERR_PACKAGE_PATH_NOT_EXPORTED
Node.js 20✗ failsERR_PACKAGE_PATH_NOT_EXPORTED✗ failsERR_PACKAGE_PATH_NOT_EXPORTED
Node.js 22✗ failsERR_PACKAGE_PATH_NOT_EXPORTED✗ failsERR_PACKAGE_PATH_NOT_EXPORTED
Node.js 24✗ failsERR_PACKAGE_PATH_NOT_EXPORTED✗ failsERR_PACKAGE_PATH_NOT_EXPORTED
Node.js 26✗ failsERR_PACKAGE_PATH_NOT_EXPORTED✗ failsERR_PACKAGE_PATH_NOT_EXPORTED
Bun 1.4.0✗ failsError✗ failsError

A failing require() on a CommonJS package usually means the package needs a browser/DOM global, a peer dependency, or a native binary that is not available in a bare Node.js process.

How to import pure-rand

ES modules (import)

import * as pureRand from "pure-rand/utils/skipN";

Namespace import shown because the ESM entry may have no default export; use named imports for what it exports.

CommonJS (require)

const pureRand = require("pure-rand/utils/skipN");

Module format by version

Derived from the type, main and exports fields of every stable release on npm, corrected where a runtime test of that version contradicted them (46 versions; the newest 46 shown).

VersionsFormatFirst published
4.1.2 – 8.4.2Dual (CommonJS + ESM)Jan 25, 2021
0.0.0 – 4.1.1CommonJSMar 1, 2018

Frequently asked

Is pure-rand ESM-only?

pure-rand@8.4.2 ships CommonJS and ESM builds, reachable only through subpaths. pure-rand exposes only subpaths in its exports map, for example "pure-rand/utils/skipN"; there is no root entry, so require("pure-rand") and import "pure-rand" both throw ERR_PACKAGE_PATH_NOT_EXPORTED. Each subpath ships a CommonJS and a native ESM build, so require("pure-rand/utils/skipN") and import "pure-rand/utils/skipN" both work.

Can I require pure-rand?

Only by subpath. require("pure-rand") throws ERR_PACKAGE_PATH_NOT_EXPORTED because the exports map has no root entry; require("pure-rand/utils/skipN") works, and so does import from the same subpath.

Does pure-rand work in Bun?

Importing pure-rand failed in Bun 1.4.0 on Sep 9, 2026: error: Cannot find package 'pure-rand' from '/Users/boat/Projects/top-seo/data/probe-work/pure-rand/imp.mjs'

Does pure-rand ship TypeScript types?

No. pure-rand ships no type declarations and there is no @types package for it.

Links

Other dual (commonjs + esm) packages

Similar popularity