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

> pure-rand@8.4.2 ships CommonJS and ESM builds, reachable only through subpaths. Dual package, subpaths only — require("pure-rand/…") works, require("pure-rand") does not.

 Pure random number generator written in TypeScript

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

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.

## Facts

- 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

## Runtime test results for pure-rand@8.4.2

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 | fails (ERR_PACKAGE_PATH_NOT_EXPORTED) | fails (ERR_PACKAGE_PATH_NOT_EXPORTED) |
| Node.js 20 | fails (ERR_PACKAGE_PATH_NOT_EXPORTED) | fails (ERR_PACKAGE_PATH_NOT_EXPORTED) |
| Node.js 22 | fails (ERR_PACKAGE_PATH_NOT_EXPORTED) | fails (ERR_PACKAGE_PATH_NOT_EXPORTED) |
| Node.js 24 | fails (ERR_PACKAGE_PATH_NOT_EXPORTED) | fails (ERR_PACKAGE_PATH_NOT_EXPORTED) |
| Node.js 26 | fails (ERR_PACKAGE_PATH_NOT_EXPORTED) | fails (ERR_PACKAGE_PATH_NOT_EXPORTED) |
| Bun 1.4.0 | fails (Error) | fails (Error) |

## How to import pure-rand

ES modules:

```js
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:

```js
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 (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

- [pure-rand on npm](https://www.npmjs.com/package/pure-rand)
- [Source repository](https://github.com/dubzzz/pure-rand)
- [HTML version](https://canirequire.com/package/pure-rand/)
- [JSON version](https://canirequire.com/package/pure-rand.json)

---

For scripts and AI agents: any package is at https://canirequire.com/package/<name>/index.md (Markdown) or https://canirequire.com/package/<name>.json (JSON); the site index is https://canirequire.com/llms.txt. Fetch the URL directly; no search needed.
