How to fix SyntaxError: The requested module does not provide an export named 'default' in Node.js

Node.jsINTERMEDIATEMEDIUMUpdated Dec 9, 2025ยท 286 views

This error occurs when importing from an ES module that doesn't export the requested name. It commonly happens when trying to use a default import on a module that only has named exports, or when mixing ESM and CommonJS module systems.

Quick fix

Fixes SyntaxError: The requested module does not provide an export named 'default'

// module.js
export function myFunction() { }
export const myValue = 42;
  1. Check the module's actual exports
  2. Match your import syntax to the export type
  3. Fix CommonJS module imports
  4. Add or fix the default export in your module
node.js โ€” error
// module.js
export function myFunction() { }
export const myValue = 42;
SyntaxError: The requested module does not provide an export named 'default'

What this error means

This SyntaxError indicates a mismatch between what you're trying to import from a module and what that module actually exports. In ES modules, there are two types of exports: default exports and named exports. When you attempt to import something that doesn't exist in the module's export list, Node.js throws this error. The most common scenario is trying to use a default import (like `import something from './module'`) when the module only exports named exports (like `export { something }`). This also frequently occurs when importing from CommonJS modules in an ES module context, because CommonJS modules don't have true default exports - they only have `module.exports`. Node.js uses static analysis (cjs-module-lexer) to detect named exports from CommonJS modules for better interoperability, but this only works reliably when CommonJS modules use direct property assignments like `exports.name = value`, not when reassigning the entire `module.exports` object.

Typical symptoms

  • Application crashes immediately on startup with SyntaxError
  • Import statement fails during module resolution
  • Error message specifies the exact export name that cannot be found
  • Issue occurs when migrating from CommonJS to ES modules
  • Problem appears after upgrading a dependency to a pure ESM package

Common causes

  1. Attempting to default import from a module that only has named exports
  2. Missing default export in the target module
  3. Importing from a CommonJS module that uses module.exports = {...} instead of exports.name
  4. Typo in the export name being imported
  5. Module configuration missing "type": "module" in package.json
  6. Importing a named export without curly braces
  7. Bundler or transpiler misconfiguration when handling ESM/CommonJS interop

How to fix "SyntaxError: The requested module does not provide an export named 'default'"

1Check the module's actual exports

Open the file you're importing from and verify what it exports. Look for either:

Named exports:

javascript
// module.js
export function myFunction() { }
export const myValue = 42;

Default export:

javascript
// module.js
export default function myFunction() { }

If you see named exports, you must use named imports with curly braces. If you see a default export, use a default import without curly braces.

2Match your import syntax to the export type

Adjust your import statement based on what the module exports:

For named exports, use curly braces:

javascript
import { myFunction, myValue } from './module.js';

For default exports, don't use curly braces:

javascript
import myFunction from './module.js';

For mixed exports:

javascript
import myDefault, { myNamed } from './module.js';
3Fix CommonJS module imports

If you're importing from a CommonJS module, use a default import and destructure:

Instead of this (will fail):

javascript
import { something } from './commonjs-module';

Use this approach:

javascript
import pkg from './commonjs-module.js';
const { something } = pkg;

Or use a namespace import:

javascript
import * as pkg from './commonjs-module.js';
pkg.something();
4Add or fix the default export in your module

If the module should have a default export but doesn't, add it:

Add a default export:

javascript
// module.js
function myFunction() {
  // implementation
}

export default myFunction;

Or export an object as default:

javascript
// module.js
const api = {
  method1() { },
  method2() { }
};

export default api;
5Verify package.json configuration

Ensure your package.json has the correct module configuration:

For ES modules, add:

json
{
  "type": "module"
}

Or use .mjs file extensions for ES modules without changing package.json.

For CommonJS (default), either omit "type" or use:

json
{
  "type": "commonjs"
}

If you have a mixed project, use explicit file extensions (.mjs for ESM, .cjs for CommonJS) instead of .js files.

Advanced notes

ESM/CommonJS Interoperability:
Node.js uses static analysis to detect CommonJS named exports, but this only works when modules use direct property assignments (exports.name = value) rather than reassigning module.exports. When a CommonJS module uses module.exports = { ... }, only default imports will work from ESM.

Third-party pure ESM packages:
Some packages (like node-fetch v3+, chalk v5+) have migrated to pure ESM and no longer support CommonJS require(). If you're in a CommonJS project, you must either migrate to ESM, use dynamic import(), or downgrade to the last CommonJS-compatible version.

TypeScript considerations:
When using TypeScript with esModuleInterop: true, the compiler allows import something from 'module' for CommonJS modules, but this may fail at runtime in Node.js. Always verify the actual module format and use appropriate import syntax.

Bundler behavior:
Build tools like webpack, Rollup, and esbuild handle ESM/CommonJS differently. Some automatically add default exports or perform synthetic default imports. This can cause code that works during development to break in production or vice versa. Always test your builds in the actual runtime environment.

Frequently asked questions

What does "SyntaxError: The requested module does not provide an export named 'de" mean?
This SyntaxError indicates a mismatch between what you're trying to import from a module and what that module actually exports. In ES modules, there are two types of exports: default exports and named exports. js throws this error.
How do I fix "SyntaxError: The requested module does not provide an export named 'de"?
This error occurs when importing from an ES module that doesn't export the requested name. It commonly happens when trying to use a default import on a module that only has named exports, or when mixing ESM and CommonJS module systems.
What causes "SyntaxError: The requested module does not provide an export named 'de"?
Attempting to default import from a module that only has named exports Missing default export in the target module Importing from a CommonJS module that uses module.exports = {...} instead of exports.name
Is the "SyntaxError: The requested module does not provide an export named 'de" error serious?
It is a medium-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading