Repository navigation
Labels
Description
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.
Reacted by Ochir Darmaev, Robbert Korving and Maxence LEFEBVRE
Activity
alumni commentedon Jun 3, 2026
#12363 added
require('expo-sqlite')inExpoDriver-> we can't userequiredirectly in code because it breaks bundlers - that's we havePlatformToolsactually. We probably need to revert that or moveexpo-sqliteloading toPlatformTools.carl-sauter commentedon Jun 19, 2026
+1 for this, same thing for react native and metro bundler.
This also applies for
const crypto = require("node:crypto");inStringUtils. 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.robkorv commentedon Jun 22, 2026
For me the workaround suggested by the OP is working. The build itself doesn't seem to increase in size by doing that.
Thanks for submitting the issue @jacobg and providing the workaround.
carl-sauter commentedon Jun 22, 2026
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.
alumni commentedon Jul 2, 2026
@jacobg @carl-sauter @robkorv Could you please try with this version:
{ "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.
carl-sauter commentedon Jul 6, 2026
@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!
robkorv commentedon Jul 7, 2026
@alumni fix works \o/. Thanks for picking it up.
alumni commentedon Jul 7, 2026
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.20260707or later should contain this fix.