canirequire › Dual (CommonJS + ESM) › fraction.js
Is fraction.js ESM-only? Can you require() it?
The RAW rational numbers library
Last verified Sep 9, 2026 against fraction.js@5.3.4. JSON
Dual (CommonJS + ESM) Dual package — both require() and import work
fraction.js publishes both a CommonJS entry and a native ESM entry (ESM added in 4.3.0). require("fraction.js") and import "fraction.js" both work on every supported Node.js version and in Bun.
Does fraction.js@5.3.4 actually load? Runtime test results
Installed and executed on Sep 9, 2026 with require("fraction.js") from a CommonJS file and import "fraction.js" from an ES module.
| Runtime | require("fraction.js") | import "fraction.js" |
|---|---|---|
| Node.js 18 | ✓ works | ✓ works |
| Node.js 20 | ✓ works | ✓ works |
| Node.js 22 | ✓ works | ✓ works |
| Node.js 24 | ✓ works | ✓ works |
| Node.js 26 | ✓ works | ✓ works |
| Bun 1.4 | ✓ works | ✓ works |
How to import fraction.js
ES modules (import)
import fractionJs from "fraction.js";CommonJS (require)
const fractionJs = require("fraction.js");Module format by version
Derived from the type, main and exports fields of every stable release on npm (70 versions; the newest 60 shown).
| Versions | Format | First published |
|---|---|---|
| 4.3.5 – 5.3.4 | Dual (CommonJS + ESM) | Sep 1, 2023 |
| 4.3.3 – 4.3.4 | CommonJS | Aug 31, 2023 |
| 4.3.0 – 4.3.2 | Dual (CommonJS + ESM) | Aug 29, 2023 |
| 2.3.0 – 4.2.1 | CommonJS | Jun 23, 2015 |
Frequently asked
Is fraction.js ESM-only?
fraction.js@5.3.4 ships CommonJS and ESM builds. fraction.js publishes both a CommonJS entry and a native ESM entry (ESM added in 4.3.0). require("fraction.js") and import "fraction.js" both work on every supported Node.js version and in Bun.
Can I require fraction.js?
Yes. fraction.js ships a CommonJS entry, so require("fraction.js") works on every Node.js version, alongside the native ESM entry for import.
Does fraction.js work in Bun?
Yes. import "fraction.js" loaded successfully in Bun 1.4 on Sep 9, 2026.
Does fraction.js ship TypeScript types?
Yes. fraction.js bundles its own type declarations; no @types package is needed.
Links
Other dual (commonjs + esm) packages
- minimatch 10.2.6Dual
- brace-expansion 5.0.9Dual
- lru-cache 11.5.2Dual
- glob 13.0.6Dual
- eslint-visitor-keys 5.0.1Dual
- yallist 5.0.0Dual
- balanced-match 4.0.4Dual
- js-yaml 5.4.1Dual
Similar popularity
- jest-changed-files 30.5.1Dual
- jest-circus 30.5.1Dual
- jest-resolve-dependencies 30.5.1Dual
- cssom 0.5.0CommonJS
- ansi-colors 4.1.3CommonJS
- eslint-plugin-jsx-a11y 6.10.2CommonJS
- diff-sequences 29.6.3CommonJS
- is-potential-custom-element-name 1.0.1CommonJS