# no-top-level-await

Rule `node/no-top-level-await`. Disallow top-level `await` in published modules

- Source: node
- Technologies: Node.js
- Kind: style
- Needs type information: no
- Autofix: no
- Reach: 0 weekly downloads of presets that enable it
- Trend: 0% last quarter
- Rank: #1765 by reach

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `n/no-top-level-await` | no | no | package `eslint-plugin-n` | [docs](https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-top-level-await.md) |
| Oxlint | `node/no-top-level-await` | no | no | plugin `node`, category restriction | [docs](https://oxc.rs/docs/guide/usage/linter/rules/node/no-top-level-await.html) |

## Code examples

### Incorrect: the rule reports this

```js
const foo = await import('foo');
for await (const e of asyncIterate()) {
    // ...
}
```

### Correct: the rule accepts this

```js
#!/usr/bin/env node
/*eslint n/no-top-level-await: ["error", { "ignoreBin": true }]*/

const foo = await import('foo');
for await (const e of asyncIterate()) {
    // ...
}
```

Examples from the ESLint documentation.

## Enable it

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

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

export default [
  {
    plugins: { n },
    rules: {
      "n/no-top-level-await": "error",
    },
  },
];
```

### Oxlint: `.oxlintrc.json`

```json
{
  "plugins": [
    "node"
  ],
  "rules": {
    "node/no-top-level-await": "error"
  }
}
```

## Related rules

- [node/prefer-node-protocol](https://lintradar.dev/rules/node/prefer-node-protocol.md): Enforce using the `node:` protocol when importing Node.js builtin modules.
- [node/no-sync](https://lintradar.dev/rules/node/no-sync.md): Disallow synchronous methods
- [node/no-process-env](https://lintradar.dev/rules/node/no-process-env.md): Disallow the use of `process.env`
- [node/prefer-process-get-builtin-module](https://lintradar.dev/rules/node/prefer-process-get-builtin-module.md): Enforce using `process.getBuiltinModule()` to load Node.js built-in modules
- [node/no-unpublished-bin](https://lintradar.dev/rules/node/no-unpublished-bin.md): Disallow `bin` files that npm ignores
- [node/file-extension-in-import](https://lintradar.dev/rules/node/file-extension-in-import.md): Enforce the style of file extensions in `import` declarations

---

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