canirequire › Dual (CommonJS + ESM) › underscore
Is underscore ESM-only? Can you require() it?
JavaScript's functional programming helper library.
Last verified Sep 9, 2026 against underscore@1.13.8. JSON
Dual (CommonJS + ESM) Dual package — both require() and import work
underscore publishes both a CommonJS entry and a native ESM entry (ESM added in 1.13.0). require("underscore") and import "underscore" both work on every supported Node.js version and in Bun.
Does underscore@1.13.8 actually load? Runtime test results
Installed and executed on Sep 9, 2026 with require("underscore") from a CommonJS file and import "underscore" from an ES module.
| Runtime | require("underscore") | import "underscore" |
|---|---|---|
| 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 underscore
ES modules (import)
import underscore from "underscore";CommonJS (require)
const underscore = require("underscore");Module format by version
Derived from the type, main and exports fields of every stable release on npm (51 versions; the newest 51 shown).
| Versions | Format | First published |
|---|---|---|
| 1.13.0 – 1.13.8 | Dual (CommonJS + ESM) | Apr 9, 2021 |
| 1.0.3 – 1.12.1 | CommonJS | Dec 7, 2011 |
Frequently asked
Is underscore ESM-only?
underscore@1.13.8 ships CommonJS and ESM builds. underscore publishes both a CommonJS entry and a native ESM entry (ESM added in 1.13.0). require("underscore") and import "underscore" both work on every supported Node.js version and in Bun.
Can I require underscore?
Yes. underscore ships a CommonJS entry, so require("underscore") works on every Node.js version, alongside the native ESM entry for import.
Does underscore work in Bun?
Yes. import "underscore" loaded successfully in Bun 1.4 on Sep 9, 2026.
Does underscore ship TypeScript types?
Not bundled. Install the community types with "npm install -D @types/underscore".
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
- babel-loader 10.1.1CommonJS
- @popperjs/core 2.11.8CommonJS
- change-case 5.4.4ESM-only
- boxen 8.0.1ESM-only
- i18next 26.4.2Dual
- lodash.clonedeep 4.5.0CommonJS
- storybook 10.6.0No entry
- @rollup/plugin-commonjs 29.0.3Dual