# Error: The edge runtime does not support Node.js 'X' module.

- **ID:** `nextjs/edge-function-cannot-access-node-module`
- **Domain:** nextjs
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 75%

## Root Cause

A module or API route configured with 'runtime: edge' tries to import a Node.js built-in module (e.g., 'fs', 'crypto', 'path') that is not available in the Edge Runtime.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| Next.js 13.5 | active | — | — |
| Next.js 14.0 | active | — | — |
| Next.js 14.2 | active | — | — |
| Next.js 15.0 | active | — | — |

## Workarounds

1. **Remove the Node.js module import and use Edge-compatible alternatives. For example, replace 'crypto' with the Web Crypto API: 'const key = await crypto.subtle.generateKey(...)'.** (80% success)
   ```
   Remove the Node.js module import and use Edge-compatible alternatives. For example, replace 'crypto' with the Web Crypto API: 'const key = await crypto.subtle.generateKey(...)'.
   ```
2. **Change the runtime to 'nodejs' in the route segment config: export const runtime = 'nodejs'; then keep the Node.js module import.** (70% success)
   ```
   Change the runtime to 'nodejs' in the route segment config: export const runtime = 'nodejs'; then keep the Node.js module import.
   ```
3. **Use dynamic imports with 'ssr: false' for the Node.js module inside a client component, but ensure the route is not edge-runtime.** (60% success)
   ```
   Use dynamic imports with 'ssr: false' for the Node.js module inside a client component, but ensure the route is not edge-runtime.
   ```

## Dead Ends

- **** — 'use client' does not change the runtime context; the edge runtime still blocks Node.js modules. The error persists because the module is loaded at build time or runtime. (90% fail)
- **** — Changing the runtime alone does not resolve the import issue; the module must be replaced or polyfilled. The error may change to a different module-related error. (70% fail)
- **** — Edge Runtime has a specific Web API subset; browser polyfills often use Node.js APIs internally and still fail. The polyfill may not be compatible with the edge sandbox. (60% fail)
