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
- TypeORM should not load MongoDB-related typings when the MongoDB driver is not being used in the project.
- 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.
- Nuxt Nitro build with
cloudflare-modulepreset 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 commandSteps to reproduce
Prerequisites
- Node.js v22.16.0
- pnpm v10.11.1
- Nuxt v4.2.2
Reproduction Steps
- Create a new Nuxt 4 project:
npx nuxi init nuxt-typeorm-bug cd nuxt-typeorm-bug pnpm install - Install TypeORM and non-MongoDB database drivers:
pnpm add typeorm better-sqlite3 mysql2 pg pnpm add -D @types/better-sqlite3 @types/pg - Configure Nuxt to use Nitro
cloudflare-modulepreset (updatenuxt.config.ts):export default defineNuxtConfig({ nitro: { preset: "cloudflare-module" }, modules: [], build: { transpile: ["typeorm"] // Optional: Attempted to fix, but issue persists } }) - Add a basic TypeORM configuration file (
ormconfig.ts) (no MongoDB configuration):import { DataSource } from "typeorm"; export const AppDataSource = new DataSource({ type: "better-sqlite3", database: "test.db", entities: ["./src/entities/**/*.ts"], synchronize: true, logging: false }); - Attempt to build the Nuxt project:
pnpm run build - 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
- The project does not use MongoDB or the TypeORM MongoDB driver, but TypeORM still loads the
browser/driver/mongodb/typings.jsfile during the Nitro build process. - 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). - 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.
- 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