# Is underscore ESM-only? Can you require() it?

> underscore@1.13.8 ships CommonJS and ESM builds. Dual package — require() works on every Node.js version we test; import works too.

JavaScript's functional programming helper library.

Last verified Sep 9, 2026 against underscore@1.13.8.

underscore publishes both a CommonJS entry and a native ESM entry (ESM added in 1.13.0). require("underscore") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. import "underscore" works alongside it.

## What to do

1. Nothing to change. require("underscore") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. import * as underscore from "underscore" works alongside it; use named imports for what the ESM entry exports.
2. TypeScript: npm install -D @types/underscore

## Facts

- 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

## Runtime test results for underscore@1.13.8

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.0 | works | works |

## How to import underscore

ES modules:

```js
import * as underscore from "underscore";
```

Namespace import shown because the ESM entry may have no default export; use named imports for what it exports.

CommonJS:

```js
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") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. import "underscore" works alongside it.

**Can I require underscore?**

Yes. underscore ships a CommonJS entry alongside the native ESM entry. require("underscore") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun.

**Does underscore work in Bun?**

Yes. import "underscore" loaded successfully in Bun 1.4.0 on Sep 9, 2026.

**Does underscore ship TypeScript types?**

Not bundled. Install the community types with "npm install -D @types/underscore".

## Links

- [underscore on npm](https://www.npmjs.com/package/underscore)
- [Source repository](https://github.com/jashkenas/underscore)
- [HTML version](https://canirequire.com/package/underscore/)
- [JSON version](https://canirequire.com/package/underscore.json)

---

For scripts and AI agents: any package is at https://canirequire.com/package/<name>/index.md (Markdown) or https://canirequire.com/package/<name>.json (JSON); the site index is https://canirequire.com/llms.txt. Fetch the URL directly; no search needed.
