# first-line

> Get the first line of a file

Latest version **6.0.0** (published 2026-11-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install first-line
pnpm add first-line
yarn add first-line
bun add first-line
```

## Health

**Score 75/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 6.0.0 |
| Published | 2026-11-09 |
| First published | 2014-10-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | ^22.12.0 \|\| 24 \|\| >=26 |
| Dependencies | 2 |
| Unpacked size | 6.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 1 |
| Author | Kenan Yildirim <kenan@kenany.me> (https://kenany.me/) |
| Maintainers | kenan |
| Keywords | fs |

## Links

- npm: https://www.npmjs.com/package/first-line
- Repository: https://github.com/kenany/first-line
- npm.io page: https://npm.io/package/first-line

## Dependencies (2)

- [once](https://npm.io/package/once.md) ^1.4.0
- [binary-split](https://npm.io/package/binary-split.md) ^2.0.0

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 6.0.0 (latest) — 2026-11-09
- 5.0.0 — 2026-05-25
- 4.0.0 — 2023-09-12
- 3.0.1 — 2023-03-22
- 3.0.0 — 2022-12-27
- 2.0.2 — 2022-04-12
- 2.0.1 — 2022-01-13
- 2.0.0 — 2021-12-20
- 1.0.9 — 2021-08-25
- 1.0.8 — 2021-04-02
- 1.0.7 — 2020-10-01
- 1.0.6 — 2020-09-29
- 1.0.5 — 2020-08-25
- 1.0.4 — 2019-06-29
- 1.0.3 — 2017-09-22
- … 3 more at https://npm.io/package/first-line/versions

## README

# first-line

Get the first line of a file.

## Example

```javascript
import { firstLine } from 'first-line';
import { resolve } from 'node:path';

const file = resolve('fixture.txt');

const line = await firstLine(file);
console.log(line);
// => '1'
```

## Installation

```bash
$ npm install first-line
```

## API

```javascript
import { firstLine } from 'first-line';
```

### `firstLine(file: string): Promise<string | null>`

Reads the file at `file` and resolves with the first line as a string, or `null`
if the file is empty or contains only newlines.

---
_Source: https://npm.io/package/first-line · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
