sjz3904
09/19/2025, 12:49 PMasync_request.ts:22 Uncaught SyntaxError: The requested module '/node_modules/@boundaryml/baml/index.js?v=ad07a5db' does not provide an export named 'HTTPRequest' (at async_request.ts:22:23)
I am new to using BAML with typescript and web dev. Any help would be appreciated.
What I have already tried -
- Downgrading to 206.1
- Deleting and regenerating files
- changing the generator to include ESM
- restarting the server (many times)
- clearing cache
https://cdn.discordapp.com/attachments/1253172394345107466/1418579853745193043/image.png?ex=68cea2f1&is=68cd5171&hm=563b25dd1b90c7748846a4fa6788b4273e63dc39a15b59b45834b776662a63af&aaronv (BAML)
09/19/2025, 2:38 PMVaibhav (BAML 🐑)
09/19/2025, 3:29 PMaaronv (BAML)
09/19/2025, 3:30 PMaaronv (BAML)
09/19/2025, 3:31 PMaaronv (BAML)
09/19/2025, 3:31 PMVaibhav (BAML 🐑)
09/19/2025, 5:13 PMVaibhav (BAML 🐑)
09/20/2025, 1:06 AMsjz3904
09/20/2025, 3:50 AMglobals.ts:25 Uncaught ReferenceError: process is not defined
at globals.ts:25:13
https://cdn.discordapp.com/attachments/1418579854714212403/1418806392529096814/image.png?ex=68cf75ec&is=68ce246c&hm=aa64e9ac2265ede9d9d49e418aad2b6243a39dec7bb58400b2ea831bdc805fa7&Vaibhav (BAML 🐑)
09/20/2025, 3:50 AMVaibhav (BAML 🐑)
09/20/2025, 3:50 AMVaibhav (BAML 🐑)
09/20/2025, 3:50 AMsjz3904
09/20/2025, 3:53 AMVaibhav (BAML 🐑)
09/20/2025, 3:54 AMVaibhav (BAML 🐑)
09/20/2025, 3:54 AMsjz3904
09/20/2025, 3:54 AMVaibhav (BAML 🐑)
09/20/2025, 3:55 AMsjz3904
09/20/2025, 3:56 AMaaronv (BAML)
09/20/2025, 7:16 PM{
"extends": "@tsconfig/node23/tsconfig.json",
"exclude": [
"dist"
],
"compilerOptions": {
"outDir": "dist",
"module": "ESNext",
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": false,
"esModuleInterop": false
}
}
the problem is the native imports are not esm compatible, and if we add --esm to the napi build script, and only support esm i think that may be the way to go.aaronv (BAML)
09/20/2025, 7:35 PMveth0119
01/13/2026, 10:29 AMVaibhav (BAML 🐑)
01/13/2026, 4:42 PMVaibhav (BAML 🐑)
01/13/2026, 4:43 PMveth0119
01/15/2026, 8:50 AMveth0119
01/15/2026, 8:50 AMReferenceError: __filename is not defined in ES module scope
at file:///var/task/chunks/_/baml_client-BqK7FfZN.mjs:4:26
... 8 lines matching cause stack trace ...
at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:665:26) {
cause: ReferenceError: __filename is not defined in ES module scope
at file:///var/task/chunks/_/baml_client-BqK7FfZN.mjs:4:26
at file:///var/task/chunks/_/rolldown-runtime.mjs:3:48
at file:///var/task/chunks/_/baml_client-BqK7FfZN.mjs:378:17
at file:///var/task/chunks/_/rolldown-runtime.mjs:3:48
at file:///var/task/chunks/_/baml_client-BqK7FfZN.mjs:847:15
at file:///var/task/chunks/_/rolldown-runtime.mjs:3:48
at file:///var/task/chunks/_/baml_client-BqK7FfZN.mjs:988:5
at ModuleJob.run (node:internal/modules/esm/module_job:345:25)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:665:26),
status: 500,
statusText: undefined,
headers: undefined,
data: undefined,
body: undefined,
unhandled: true
}veth0119
01/15/2026, 8:58 AMveth0119
01/15/2026, 9:48 AMtest/bun-runtime
This branch demonstrates that using Bun runtime instead of Node.js avoids the ESM __filename error.
### Why Bun Works
Bun provides built-in compatibility for CommonJS globals (__filename, __dirname, require) in ESM modules, unlike Node.js which strictly enforces ESM semantics.
### How to Use
```bash
# Clone this branch
git clone -b test/bun-runtime https://github.com/Haoxincode/vercel-baml-esm-error.git
cd vercel-baml-esm-error
# Install & build with Bun
bun install
bun run build
# Run - NO ERROR!
bun run start
Vercel Deployment
This branch includes vercel.json configured with Bun runtime:
{
"bunVersion": "1.x"
}
Deploy this branch to Vercel and it should work without the ESM error.Vaibhav (BAML 🐑)
01/15/2026, 3:10 PM