canirequire › Dual (CommonJS + ESM) › dedent
Is dedent ESM-only? Can you require() it?
A string tag that strips indentation from multi-line strings. ⬅️
Last verified Sep 9, 2026 against dedent@1.7.2. JSON
Dual (CommonJS + ESM) Dual package — both require() and import work
dedent publishes both a CommonJS entry and a native ESM entry (ESM added in 1.3.0). require("dedent") and import "dedent" both work on every supported Node.js version and in Bun.
Does dedent@1.7.2 actually load? Runtime test results
Installed and executed on Sep 9, 2026 with require("dedent") from a CommonJS file and import "dedent" from an ES module.
| Runtime | require("dedent") | import "dedent" |
|---|---|---|
| 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 dedent
ES modules (import)
import dedent from "dedent";CommonJS (require)
const dedent = require("dedent");Module format by version
Derived from the type, main and exports fields of every stable release on npm (24 versions; the newest 24 shown).
| Versions | Format | First published |
|---|---|---|
| 1.3.0 – 1.7.2 | Dual (CommonJS + ESM) | Jul 27, 2023 |
| 0.1.0 – 1.2.0 | CommonJS | Jan 13, 2015 |
Frequently asked
Is dedent ESM-only?
dedent@1.7.2 ships CommonJS and ESM builds. dedent publishes both a CommonJS entry and a native ESM entry (ESM added in 1.3.0). require("dedent") and import "dedent" both work on every supported Node.js version and in Bun.
Can I require dedent?
Yes. dedent ships a CommonJS entry, so require("dedent") works on every Node.js version, alongside the native ESM entry for import.
Does dedent work in Bun?
Yes. import "dedent" loaded successfully in Bun 1.4 on Sep 9, 2026.
Does dedent ship TypeScript types?
Yes. dedent 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
- postcss-load-config 6.0.1CommonJS
- char-regex 2.0.2ESM-only
- decimal.js-light 2.5.1CommonJS
- is-binary-path 3.0.0ESM-only
- get-package-type 0.1.0CommonJS
- rfdc 1.4.1CommonJS
- is-boolean-object 1.2.2CommonJS
- typed-array-buffer 1.0.3CommonJS