canirequire › Dual (CommonJS + ESM) › lines-and-columns
Is lines-and-columns ESM-only? Can you require() it?
Maps lines and columns to character offsets and back.
Last verified Sep 9, 2026 against lines-and-columns@2.0.4. JSON
Dual (CommonJS + ESM) Dual package — both require() and import work
lines-and-columns publishes both a CommonJS entry and a native ESM entry (ESM added in 1.1.7). require("lines-and-columns") and import "lines-and-columns" both work on every supported Node.js version and in Bun.
Does lines-and-columns@2.0.4 actually load? Runtime test results
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 | ✓ works | ✓ works |
How to import lines-and-columns
ES modules (import)
import linesAndColumns from "lines-and-columns";CommonJS (require)
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") and import "lines-and-columns" both work on every supported Node.js version and in Bun.
Can I require lines-and-columns?
Yes. lines-and-columns ships a CommonJS entry, so require("lines-and-columns") works on every Node.js version, alongside the native ESM entry for import.
Does lines-and-columns work in Bun?
Yes. import "lines-and-columns" loaded successfully in Bun 1.4 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
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
- safer-buffer 2.1.2CommonJS
- @smithy/types 4.18.0CommonJS
- run-parallel 1.2.0CommonJS
- is-docker 4.0.0ESM-only
- rollup 4.63.1Dual
- once 1.4.0CommonJS
- queue-microtask 1.2.3CommonJS
- lodash.merge 4.6.2CommonJS