canirequire

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

Latest
1.13.8 (Feb 19, 2026)
Module format
Dual (CommonJS + ESM)
Last CommonJS version
1.13.8
Native ESM since
1.13.0
TypeScript types
@types/underscore
Node engines
not declared
Weekly downloads
20.1M
License
MIT

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.

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

VersionsFormatFirst published
1.13.0 – 1.13.8Dual (CommonJS + ESM)Apr 9, 2021
1.0.3 – 1.12.1CommonJSDec 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

Similar popularity