canirequire

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

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

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.

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

VersionsFormatFirst published
2.0.2 – 2.0.4Dual (CommonJS + ESM)Nov 20, 2021
2.0.0 – 2.0.1ESM-onlyNov 20, 2021
1.2.3 – 1.2.4CommonJSNov 21, 2021
1.2.2ESM-onlyNov 21, 2021
1.2.1Dual (CommonJS + ESM)Nov 20, 2021
1.2.0ESM-onlyNov 20, 2021
1.1.10 – 1.1.11CommonJSNov 21, 2021
1.1.9Dual (CommonJS + ESM)Nov 20, 2021
1.1.7 – 1.1.8ESM-onlyNov 20, 2021
1.0.0 – 1.1.6CommonJSDec 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

Similar popularity