canirequire

canirequireDual (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.

Latest
5.3.4 (Aug 22, 2025)
Module format
Dual (CommonJS + ESM)
Last CommonJS version
5.3.4
Native ESM since
4.3.0
TypeScript types
Bundled
Node engines
*
Weekly downloads
41.7M
License
MIT

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.

Runtimerequire("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).

VersionsFormatFirst published
4.3.5 – 5.3.4Dual (CommonJS + ESM)Sep 1, 2023
4.3.3 – 4.3.4CommonJSAug 31, 2023
4.3.0 – 4.3.2Dual (CommonJS + ESM)Aug 29, 2023
2.3.0 – 4.2.1CommonJSJun 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

Similar popularity