canirequire

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

  1. 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.
  2. TypeScript: types are bundled; install nothing extra.
Latest
2.0.20 (Apr 16, 2023)
Module format
Dual (CommonJS + ESM)
Last CommonJS version
2.0.20
Native ESM since
1.2.1
TypeScript types
Bundled
Node engines
not declared
Weekly downloads
52.9M
License
MIT

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.

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

VersionsFormatFirst published
1.2.1 โ€“ 2.0.20Dual (CommonJS + ESM)Jul 5, 2020
0.1.0 โ€“ 1.2.0CommonJSAug 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

Similar popularity