canirequire โบ Dual (CommonJS + ESM) โบ colorette
Is colorette ESM-only? Can you require() it?
๐Easily set your terminal text color & styles.
Last verified Sep 9, 2026 against colorette@2.0.20. Markdown ยท JSON
Dual (CommonJS + ESM) Dual package โ require() works on every Node.js version we test; import works too
colorette publishes both a CommonJS entry and a native ESM entry (ESM added in 1.2.1). require("colorette") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. import "colorette" works alongside it.
What to do
- Nothing to change. require("colorette") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. import * as colorette from "colorette" works alongside it; use named imports for what the ESM entry exports.
- TypeScript: types are bundled; install nothing extra.
Does colorette@2.0.20 actually load? Runtime test results
Installed and executed on Sep 9, 2026 with require("colorette") from a CommonJS file and import "colorette" from an ES module.
| Runtime | require("colorette") | import "colorette" |
|---|---|---|
| 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.0 | โ works | โ works |
How to import colorette
ES modules (import)
import * as colorette from "colorette";Namespace import shown because the ESM entry may have no default export; use named imports for what it exports.
CommonJS (require)
const colorette = require("colorette");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 (37 versions; the newest 37 shown).
| Versions | Format | First published |
|---|---|---|
| 1.2.1 โ 2.0.20 | Dual (CommonJS + ESM) | Jul 5, 2020 |
| 0.1.0 โ 1.2.0 | CommonJS | Aug 23, 2018 |
Frequently asked
Is colorette ESM-only?
colorette@2.0.20 ships CommonJS and ESM builds. colorette publishes both a CommonJS entry and a native ESM entry (ESM added in 1.2.1). require("colorette") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. import "colorette" works alongside it.
Can I require colorette?
Yes. colorette ships a CommonJS entry alongside the native ESM entry. require("colorette") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun.
Does colorette work in Bun?
Yes. import "colorette" loaded successfully in Bun 1.4.0 on Sep 9, 2026.
Does colorette ship TypeScript types?
Yes. colorette 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
- 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
- @csstools/css-tokenizer 4.0.0ESM-only
- @jest/fake-timers 30.5.1Dual
- bignumber.js 11.1.5Dual
- @jest/environment 30.5.1CommonJS
- jest-validate 30.5.1Dual
- isobject 4.1.1CommonJS
- proc-log 7.0.0CommonJS
- safe-stable-stringify 2.5.0Dual