# no-assign-module-variable

Rule `nextjs/no-assign-module-variable`. Prevent assignment to the `module` variable.

- Source: nextjs
- Technologies: Next.js, React
- Kind: correctness
- Needs type information: no
- Autofix: no
- Reach: 99.7M weekly downloads of presets that enable it
- Trend: +49.8% last quarter
- Rank: #163 by reach, #830 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `@next/next/no-assign-module-variable` | yes | no | package `@next/eslint-plugin-next` | [docs](https://nextjs.org/docs/messages/no-assign-module-variable) |
| Oxlint | `nextjs/no-assign-module-variable` | no | no | plugin `nextjs`, category correctness | [docs](https://oxc.rs/docs/guide/usage/linter/rules/nextjs/no-assign-module-variable.html) |

## Code examples

### Incorrect: the rule reports this

```js
// Declaring module variable
let module = {};

// Using module in variable declaration
const module = {
  exports: {}
};

// Assigning to module
module = { id: 'my-module' };
```

### Correct: the rule accepts this

```js
// Use a different variable name
let myModule = {};

// Use a more descriptive name
const customModule = {
  exports: {}
};

// Access actual module object (when available)
console.log(module.exports);
```

Examples from the Oxlint documentation.

## Enable it

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

```js
import next from "@next/eslint-plugin-next";

export default [
  {
    plugins: { "@next/next": next },
    rules: {
      "@next/next/no-assign-module-variable": "error",
    },
  },
];
```

### Oxlint: `.oxlintrc.json`

```json
{
  "plugins": [
    "nextjs"
  ],
  "rules": {
    "nextjs/no-assign-module-variable": "error"
  }
}
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [Next.js recommended](https://lintradar.dev/presets/next-recommended.md) | ESLint | `@next/eslint-plugin-next` | 22 | 52.9M | +50.7% |
| [Next.js Core Web Vitals](https://lintradar.dev/presets/next-core-web-vitals.md) | ESLint | `eslint-config-next` | 62 | 46.8M | +48.8% |

## Related rules

- [nextjs/no-before-interactive-script-outside-document](https://lintradar.dev/rules/nextjs/no-before-interactive-script-outside-document.md): Prevent usage of `next/script`'s `beforeInteractive` strategy outside of `pages/_document.js`.
- [nextjs/no-css-tags](https://lintradar.dev/rules/nextjs/no-css-tags.md): Prevent manual stylesheet tags.
- [nextjs/no-async-client-component](https://lintradar.dev/rules/nextjs/no-async-client-component.md): Prevent Client Components from being async functions.
- [nextjs/no-duplicate-head](https://lintradar.dev/rules/nextjs/no-duplicate-head.md): Prevent duplicate usage of `<Head>` in `pages/_document.js`.
- [nextjs/next-script-for-ga](https://lintradar.dev/rules/nextjs/next-script-for-ga.md): Prefer `@next/third-parties/google` when using the inline script for Google Analytics and Tag Manager.
- [nextjs/no-html-link-for-pages](https://lintradar.dev/rules/nextjs/no-html-link-for-pages.md): Prevent usage of `<a>` elements to navigate to internal Next.js pages.

---

Web page: https://lintradar.dev/rules/nextjs/no-assign-module-variable. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
