Skip to content

Build fails on version 1 due to failed resolution of expo-sqlite #12559

Description

@jacobg

Issue description

Build fails on version 1 due to failed resolution of expo-sqlite

Expected Behavior

After updating to typeorm version 1, expect npm run build of my application to succeed.

Actual Behavior

Build fails with this error, even though my app does not use expo. It uses capacitor.

error during build:
Build failed with 1 error:

Error: [vite]: Rolldown failed to resolve import "expo-sqlite" from "/Users/jacob/repositories/f-next/node_modules/typeorm/browser/driver/expo/ExpoDriver.js".
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
`build.rolldownOptions.external`
    at viteLog (file:///Users/jacob/repositories/f-next/node_modules/vite/dist/node/chunks/node.js:33346:57)
    at onRollupLog (file:///Users/jacob/repositories/f-next/node_modules/vite/dist/node/chunks/node.js:33378:7)
    at onLog (file:///Users/jacob/repositories/f-next/node_modules/vite/dist/node/chunks/node.js:33146:4)
    at file:///Users/jacob/repositories/f-next/node_modules/rolldown/dist/shared/rolldown-build-CrPk_lZe.mjs:50:26
    at logger (file:///Users/jacob/repositories/f-next/node_modules/rolldown/dist/shared/rolldown-build-CrPk_lZe.mjs:41:3)
    at aggregateBindingErrorsIntoJsError (file:///Users/jacob/repositories/f-next/node_modules/rolldown/dist/shared/error-BuvQYXuZ.mjs:48:18)
    at unwrapBindingResult (file:///Users/jacob/repositories/f-next/node_modules/rolldown/dist/shared/error-BuvQYXuZ.mjs:18:128)
    at #build (file:///Users/jacob/repositories/f-next/node_modules/rolldown/dist/shared/rolldown-build-CrPk_lZe.mjs:3246:34)
    at async buildEnvironment (file:///Users/jacob/repositories/f-next/node_modules/vite/dist/node/chunks/node.js:33253:64)
    at async Object.build (file:///Users/jacob/repositories/f-next/node_modules/vite/dist/node/chunks/node.js:33675:19)
    at async Object.buildApp (file:///Users/jacob/repositories/f-next/node_modules/vite/dist/node/chunks/node.js:33672:153)
    at async CAC.<anonymous> (file:///Users/jacob/repositories/f-next/node_modules/vite/dist/node/cli.js:777:3) {
  errors: [Getter/Setter]

I am able to work around and get build to work by adding to vite.config.ts:

rolldownOptions: {
   external: ['expo-sqlite']
}

But it doesn't seem that this should be necessary, given that my app doesn't use expo and no other drivers have this issue. It seems unintended.

Steps to reproduce

npm run build

My Environment

Dependency Version
Operating System
Node.js version x.y.zzz
Typescript version x.y.zzz
TypeORM version x.y.zzz

Additional Context

No response

Relevant Database Driver(s)

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

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

No, I don’t have the time and I’m okay to wait for the community / maintainers to resolve this issue.

Activity

  1. alumni commented on Jun 3, 2026

    @alumni
    Collaborator

    #12363 added require('expo-sqlite') in ExpoDriver -> we can't use require directly in code because it breaks bundlers - that's we have PlatformTools actually. We probably need to revert that or move expo-sqlite loading to PlatformTools.

  2. carl-sauter commented on Jun 19, 2026

    @carl-sauter

    +1 for this, same thing for react native and metro bundler.

    This also applies for const crypto = require("node:crypto"); in StringUtils. Looking forward for a fix, in react native you have to either stub the modules or patch the package and comment out the require calls.

  3. robkorv commented on Jun 22, 2026

    @robkorv
    Contributor

    For me the workaround suggested by the OP is working. The build itself doesn't seem to increase in size by doing that.

    I am able to work around and get build to work by adding to vite.config.ts:

    rolldownOptions: {
       external: ['expo-sqlite']
    }
    

    Thanks for submitting the issue @jacobg and providing the workaround.

  4. carl-sauter commented on Jun 22, 2026

    @carl-sauter

    The problem is that this is any undocumented vite rolldown specific workaround. Any other bundler including metro and expo for react native need another workaround.
    React Native is not working at the moment. I needed to patch the typeorm package und comment out the requires.

  5. alumni commented on Jul 2, 2026

    @alumni
    Collaborator

    @jacobg @carl-sauter @robkorv Could you please try with this version:

    npm i https://pkg.pr.new/typeorm@12647
    {
      "dependencies": {
        "typeorm": "https://pkg.pr.new/typeorm/typeorm/typeorm@e03f7a5"
      }
    }

    (either of the links should work, one is for the PR, one for the commit)

    Also, if you are using other bundlers, feedback would be great, especially for non-Node platforms where issue reproduction is more difficult.

  6. carl-sauter commented on Jul 6, 2026

    @carl-sauter

    @alumni Thank you for the fix. I tried it in react-native with metro bundler and it seems fine for me. I didn't tested the hashing functionality, however bundling is working!

  7. reopened this on Jul 6, 2026
  8. robkorv commented on Jul 7, 2026

    @robkorv
    Contributor

    @alumni fix works \o/. Thanks for picking it up.

  9. alumni commented on Jul 7, 2026

    @alumni
    Collaborator

    Thanks for checking. Will be released in 1.1.0 soon (in the coming days).

    Until then, if you need a package from npm, 1.0.0-nightly.20260707 or later should contain this fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions