Baike.dev
All toolsAI codingTrendingOpen sourceNewsSubmit
Log in
Back to tool/Back to issues
#11872·typeorm

TypeORM Issue: MongoDB Typings Export Missing Causes Rollup Build Failure in Nuxt Nitro Cloudflare Module Preset

Author: CaoMeiYouRenCreated Dec 25, 2025Updated Sep 3, 2026
Labelsbug

Issue description

When building a Nuxt 4 project with Nitro preset cloudflare-module (for Cloudflare Workers/Modules), TypeORM's internal MongoDB typings file attempts to import multiple unexported identifiers from a sibling typings file, leading to a Rollup build error and failed project compilation. This issue occurs even when the project does not use the MongoDB driver (using better-sqlite3/mysql2/pg instead).

Expected Behavior

  1. TypeORM should not load MongoDB-related typings when the MongoDB driver is not being used in the project.
  2. If MongoDB typings are loaded, all required identifiers (BSONRegExp, Binary, ObjectId, etc.) should be properly exported from the dependency typings file to avoid build errors.
  3. Nuxt Nitro build with cloudflare-module preset should complete successfully without TypeORM-related export errors.

Actual Behavior

During the Nuxt Nitro server build phase, Rollup throws multiple "is not exported by" errors for MongoDB-related identifiers in TypeORM's typings files. The build ultimately fails with exit code 1.

Error Log Snippet

node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/typeorm/browser/driver/mongodb/typings.js (1:9): "BSONRegExp" is not exported by "node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/typeorm/browser/driver/mongodb/bson.typings.js", imported by "node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/typeorm/browser/driver/mongodb/typings.js".
node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/typeorm/browser/driver/mongodb/typings.js (1:21): "BSONSymbol" is not exported by "node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/typeorm/browser/driver/mongodb/bson.typings.js", imported by "node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/typeorm/browser/driver/mongodb/typings.js".
node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/typeorm/browser/driver/mongodb/typings.js (1:43): "Binary" is not exported by "node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/typeorm/browser/driver/mongodb/bson.typings.js", imported by "node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/typeorm/browser/driver/mongodb/typings.js".
node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/typeorm/browser/driver/mongodb/typings.js (1:113): "ObjectId" is not exported by "node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/typeorm/browser/driver/mongodb/bson.typings.js", imported by "node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/typeorm/browser/driver/mongodb/typings.js".

[error] node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/typeorm/browser/driver/mongodb/typings.js (1:43): "Binary" is not exported by "node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/typeorm/browser/driver/mongodb/bson.typings.js", imported by "node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/typeorm/browser/driver/mongodb/typings.js".
 ELIFECYCLE  Command failed with exit code 1.
Failed: error occurred while running build command

Steps to reproduce

Prerequisites

  • Node.js v22.16.0
  • pnpm v10.11.1
  • Nuxt v4.2.2

Reproduction Steps

  1. Create a new Nuxt 4 project:
    bash
    npx nuxi init nuxt-typeorm-bug
    cd nuxt-typeorm-bug
    pnpm install
  2. Install TypeORM and non-MongoDB database drivers:
    bash
    pnpm add typeorm better-sqlite3 mysql2 pg
    pnpm add -D @types/better-sqlite3 @types/pg
  3. Configure Nuxt to use Nitro cloudflare-module preset (update nuxt.config.ts):
    typescript
    export default defineNuxtConfig({
      nitro: {
        preset: "cloudflare-module"
      },
      modules: [],
      build: {
        transpile: ["typeorm"] // Optional: Attempted to fix, but issue persists
      }
    })
  4. Add a basic TypeORM configuration file (ormconfig.ts) (no MongoDB configuration):
    typescript
    import { DataSource } from "typeorm";
    
    export const AppDataSource = new DataSource({
      type: "better-sqlite3",
      database: "test.db",
      entities: ["./src/entities/**/*.ts"],
      synchronize: true,
      logging: false
    });
  5. Attempt to build the Nuxt project:
    bash
    pnpm run build
  6. Observe the Rollup export errors related to TypeORM's MongoDB typings and build failure.

My Environment

Dependency Version
Operating System Linux (CI/CD Build Environment, Ubuntu/Debian-based)
Node.js version 22.16.0
Typescript version 5.9.3
TypeORM version 0.3.28
Nuxt version 4.2.2
Nitro version 2.12.9
Package Manager pnpm 10.11.1
Database Drivers better-sqlite3 12.5.0, mysql2 3.16.0, pg 8.16.3

Additional Context

  1. The project does not use MongoDB or the TypeORM MongoDB driver, but TypeORM still loads the browser/driver/mongodb/typings.js file during the Nitro build process.
  2. The build preset (cloudflare-module) targets Cloudflare Workers, which requires server-side code to be bundled by Rollup (used by Nitro/Vite under the hood).
  3. Attempted workarounds (transpiling TypeORM, excluding MongoDB files via Rollup config) did not resolve the issue, as the MongoDB typings are still being imported internally by TypeORM.
  4. The error occurs during the "Building Nuxt Nitro server" phase, after successful client and server bundle builds.

Relevant Database Driver(s)

  • aurora-mysql
  • aurora-postgres
  • better-sqlite3
  • cockroachdb
  • cordova
  • expo
  • mongodb
  • mysql
  • nativescript
  • oracle
  • postgres
  • react-native
  • sap
  • spanner
  • sqlite
  • sqlite-abstract
  • sqljs
  • sqlserver

Are you willing to resolve this issue by submitting a Pull Request?

No, I am not familiar enough with TypeORM's internal typings structure and build process to confidently submit a fix at this time.

Source: typeorm/typeorm

View original on GitHubView discussion on GitHub