https://www.boundaryml.com logo
🟡 Error Importing Module from @boundaryml/baml in...
# questions
e
why do i get this error: >
Copy code
import { toBamlError, HTTPRequest, ClientRegistry } from "@boundaryml/baml"
>                       ^
> SyntaxError: The requested module '@boundaryml/baml' does not provide an export named 'HTTPRequest'
>     at #_instantiate (node:internal/modules/esm/module_job:254:21)
>     at async ModuleJob.run (node:internal/modules/esm/module_job:369:5)
>     at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:691:26)
>     at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:101:5)
minimal repo to reproduce this: https://github.com/emilsoman/baml-hono error occurs on "npm run dev"
@Vaibhav (BAML 🐑) 's PR from 6 months ago was closed but seems like this isn't fixed yet? how are users currently able to use it in typescript? wondering if there's a straightforward workaround that i'm missing
v
Oh interesting. What version are you on? It should have been fixed!
e
"@boundaryml/baml": "^0.220.0"
if you want to reproduce the issue: https://github.com/emilsoman/baml-hono
v
awesome thank you. We'll take this on as a friday fix!
m
Hi , I tried reproducing this using your repo and ran into the same issue. It looks like
HTTPRequest
is only exported as a type but is being imported as a runtime export, which causes the ESM error in Node. I opened a small fix PR here in case it helps: https://github.com/BoundaryML/baml/pull/3237 Happy to adjust if there's a preferred way to handle it.
e
@Vaibhav (BAML 🐑) how are typescript users currently working around this?