# hashbang

Rule `node/hashbang`. Require correct usage of hashbang

- Source: node
- Technologies: Node.js
- Kind: correctness
- Needs type information: no
- Autofix: yes, in at least one linter
- Reach: 10M weekly downloads of presets that enable it
- Trend: +17.8% last quarter
- Rank: #894 by reach, #1391 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `n/hashbang` | yes | safe | package `eslint-plugin-n` | [docs](https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/hashbang.md) |

## Code examples

### Incorrect: the rule reports this

```js
console.log("hello"); /*error This file needs hashbang "#!/usr/bin/env node".*/
```

```js
#!/usr/bin/env node  /*error This file must not have Unicode BOM.*/
console.log("hello");
// If this file has Unicode BOM.
```

```js
#!/usr/bin/env node  /*error This file must have Unix linebreaks (LF).*/
console.log("hello");
// If this file has Windows' linebreaks (CRLF).
```

### Correct: the rule accepts this

```js
#!/usr/bin/env node
console.log("hello");
```

```js
console.log("hello");
```

Examples from the ESLint documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
import n from "eslint-plugin-n";

export default [
  {
    plugins: { n },
    rules: {
      "n/hashbang": "error",
    },
  },
];
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [Node.js recommended](https://lintradar.dev/presets/n-recommended.md) | ESLint | `eslint-plugin-n` | 11 | 10M | +17.8% |

## Related rules

- [node/no-process-exit](https://lintradar.dev/rules/node/no-process-exit.md): Disallow the use of `process.exit()`
- [node/no-extraneous-require](https://lintradar.dev/rules/node/no-extraneous-require.md): Disallow `require()` expressions which import extraneous modules
- [node/no-missing-import](https://lintradar.dev/rules/node/no-missing-import.md): Disallow `import` declarations which import missing modules
- [node/no-missing-require](https://lintradar.dev/rules/node/no-missing-require.md): Disallow `require()` expressions which import missing modules
- [node/no-unpublished-import](https://lintradar.dev/rules/node/no-unpublished-import.md): Disallow `import` declarations which import private modules
- [node/no-unpublished-require](https://lintradar.dev/rules/node/no-unpublished-require.md): Disallow `require()` expressions which import private modules

---

Web page: https://lintradar.dev/rules/node/hashbang. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
