# Is lines-and-columns ESM-only? Can you require() it?

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

Maps lines and columns to character offsets and back.

Last verified Sep 9, 2026 against lines-and-columns@2.0.4.

lines-and-columns publishes both a CommonJS entry and a native ESM entry (ESM added in 1.1.7). require("lines-and-columns") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. The package declares Node.js ^12.20.0 || ^14.13.1 || >=16.0.0. import "lines-and-columns" works alongside it.

## What to do

1. Nothing to change. require("lines-and-columns") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. The package declares Node.js ^12.20.0 || ^14.13.1 || >=16.0.0. import * as linesAndColumns from "lines-and-columns" works alongside it; use named imports for what the ESM entry exports.
2. TypeScript: types are bundled; install nothing extra.

## Facts

- Latest: 2.0.4 (Nov 7, 2023)
- Module format: Dual (CommonJS + ESM)
- Last CommonJS version: 2.0.4
- Native ESM since: 1.1.7
- TypeScript types: bundled
- Node engines: ^12.20.0 || ^14.13.1 || >=16.0.0
- Weekly downloads: 109.8M
- License: MIT

## Runtime test results for lines-and-columns@2.0.4

Installed and executed on Sep 9, 2026 with require("lines-and-columns") from a CommonJS file and import "lines-and-columns" from an ES module.

| Runtime | require("lines-and-columns") | import "lines-and-columns" |
|---|---|---|
| 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 lines-and-columns

ES modules:

```js
import * as linesAndColumns from "lines-and-columns";
```

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

CommonJS:

```js
const linesAndColumns = require("lines-and-columns");
```

## Module format by version

Derived from the type, main and exports fields of every stable release on npm (25 versions; the newest 25 shown).

| Versions | Format | First published |
|---|---|---|
| 2.0.2 – 2.0.4 | Dual (CommonJS + ESM) | Nov 20, 2021 |
| 2.0.0 – 2.0.1 | ESM-only | Nov 20, 2021 |
| 1.2.3 – 1.2.4 | CommonJS | Nov 21, 2021 |
| 1.2.2 | ESM-only | Nov 21, 2021 |
| 1.2.1 | Dual (CommonJS + ESM) | Nov 20, 2021 |
| 1.2.0 | ESM-only | Nov 20, 2021 |
| 1.1.10 – 1.1.11 | CommonJS | Nov 21, 2021 |
| 1.1.9 | Dual (CommonJS + ESM) | Nov 20, 2021 |
| 1.1.7 – 1.1.8 | ESM-only | Nov 20, 2021 |
| 1.0.0 – 1.1.6 | CommonJS | Dec 2, 2015 |

## Frequently asked

**Is lines-and-columns ESM-only?**

lines-and-columns@2.0.4 ships CommonJS and ESM builds. lines-and-columns publishes both a CommonJS entry and a native ESM entry (ESM added in 1.1.7). require("lines-and-columns") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. The package declares Node.js ^12.20.0 || ^14.13.1 || >=16.0.0. import "lines-and-columns" works alongside it.

**Can I require lines-and-columns?**

Yes. lines-and-columns ships a CommonJS entry alongside the native ESM entry. require("lines-and-columns") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. The package declares Node.js ^12.20.0 || ^14.13.1 || >=16.0.0.

**Does lines-and-columns work in Bun?**

Yes. import "lines-and-columns" loaded successfully in Bun 1.4.0 on Sep 9, 2026.

**Does lines-and-columns ship TypeScript types?**

Yes. lines-and-columns bundles its own type declarations; no @types package is needed.

## Links

- [lines-and-columns on npm](https://www.npmjs.com/package/lines-and-columns)
- [Source repository](https://github.com/eventualbuddha/lines-and-columns)
- [HTML version](https://canirequire.com/package/lines-and-columns/)
- [JSON version](https://canirequire.com/package/lines-and-columns.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.
