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
- 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.
- TypeScript: no types are available for pure-rand; declare the module yourself if you need them.
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.
| Runtime | require("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).
| Versions | Format | First published |
|---|---|---|
| 4.1.2 – 8.4.2 | Dual (CommonJS + ESM) | Jan 25, 2021 |
| 0.0.0 – 4.1.1 | CommonJS | Mar 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
- minimatch 10.2.6Dual
- brace-expansion 5.0.9Dual
- lru-cache 11.5.2Dual
- tslib 2.8.1Dual
- glob 13.0.6Dual
- eslint-visitor-keys 5.0.1Dual
- yallist 5.0.0Dual
- balanced-match 4.0.4Dual
Similar popularity
- socks 2.8.10CommonJS
- unplugin 3.3.0ESM-only
- deep-eql 5.0.2ESM-only
- socks-proxy-agent 10.1.0ESM-only
- array-includes 3.1.9CommonJS
- setimmediate 1.0.5CommonJS
- loader-utils 3.3.1CommonJS
- jsonwebtoken 9.0.3CommonJS