Skip to content

SyntaxError: The requested module 'mariadb' does not provide an export named 'default' in Node.js v24+ #6

@adbarbosa

Description

@adbarbosa

Environment:

  • Node.js: v24.14.0 (or other versions using strict ESM)
  • Package: mariadb-mcp-server

Description:

When running the MCP server on recent Node.js versions, the server fails to start with the following error:
SyntaxError: The requested module 'mariadb' does not provide an export named 'default'

This happens because the mariadb driver (a CommonJS module) is being imported using a default import syntax in an ESM context within dist/connection.js, which is not supported by the driver's current export structure in newer Node.js runtimes.

Current Code in dist/connection.js:

import mariadb from "mariadb";

Suggested Fix:

To ensure compatibility across different Node.js versions and ESM/CJS boundaries, the import should be handled using createRequire or a namespace import.

Revised Code:

import { createRequire } from "module";
const require = createRequire(import.meta.url);
const mariadb = require("mariadb");

Alternatively, if you prefer to keep standard ESM imports, ensure the mariadb package supports it or use:

import * as mariadb from "mariadb";

Steps to Reproduce:

  1. Install mariadb-mcp-server globally or via npx.
  2. Run using Node.js v24.14.0+.
  3. Observe the crash during the initialization phase.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions