# Error: The Edge Runtime does not support Node.js API 'X'. Use 'edge-runtime' compatible APIs.

- **ID:** `nextjs/middleware-edge-runtime-node-api`
- **Domain:** nextjs
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 95%

## Root Cause

Middleware in Next.js runs on the Edge Runtime, which has a limited set of APIs compared to Node.js. Using Node.js-specific modules like 'fs', 'path', or 'crypto' (without Web Crypto) throws this error.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| next@13.4.0 | active | — | — |
| next@14.0.0 | active | — | — |
| next@15.0.0 | active | — | — |

## Workarounds

1. **Move Node.js-dependent logic out of middleware into a separate API route or server component.** (95% success)
   ```
   Move Node.js-dependent logic out of middleware into a separate API route or server component.
   ```
2. **Use Web APIs available in Edge Runtime, such as Web Crypto (crypto.subtle) instead of Node.js crypto.** (85% success)
   ```
   Use Web APIs available in Edge Runtime, such as Web Crypto (crypto.subtle) instead of Node.js crypto.
   ```

## Dead Ends

- **** — The Edge Runtime does not have a file system; any import of 'fs' will fail at runtime. (95% fail)
- **** — Dynamic imports also run on the Edge Runtime and are blocked; they don't fall back to Node.js. (90% fail)
