# import/no-nodejs-modules

> Disallow importing Node.js builtin modules such as `fs` and `path`

Browsers don't have an `fs`, `path` or `crypto` module. Importing one either breaks the bundle or pulls in a large polyfill. Turn this rule on for the files that ship to the client.

It checks `import`, `export ... from`, `import()` and `require()`, with and without the `node:` prefix.

{/* Generated by src/codegen/lint-rule-docs.ts. Do not edit this section. */}

## Configure

Off by default. To turn it on:

```toml bunfig.toml
[lint.rules]
"import/no-nodejs-modules" = "error" # or "warn"
```

Every option, set to its default:

```toml bunfig.toml
[lint.rules]
"import/no-nodejs-modules" = ["error", {
  allow = [], # list of strings
}]
```

{/* End of the generated section. */}

## Examples

Reported:

{/* bad {"count": 3} */}
```js
import fs from "fs";
import { join } from "node:path";

const os = require("os");
```

Not reported:

{/* good */}
```js
import { format } from "date-fns";
import { cart } from "./cart";
```

## Options

| Option | Default | What it does |
| --- | --- | --- |
| `allow` | `[]` | Builtin modules you can import, spelled the way the import spells them. `"path"` doesn't allow `"node:path"`. |

{/* good {"options": [{"allow": ["node:path"]}]} */}
```js
import { join } from "node:path";
```

{/* bad {"options": [{"allow": ["node:path"]}]} */}
```js
import { join } from "path";
```
