Applies to:
Summary
Error: The Braintrust eval CLI fails with “import.meta.url is undefined” errors when evaluating packages that use ESM imports. Cause: The CLI bundles packages during evaluation, losing ESM module context and causing import.meta.url to be undefined. Solution: Use the--external-packages flag to prevent bundling of packages that require ESM context.
Resolution Steps
Step 1: Identify packages using ESM imports
Look for packages in your evaluation code that useimport.meta.url or other ESM-specific features.
Step 2: Add external packages flag
Use the--external-packages flag to mark these packages as external dependencies:
Step 3: Test the evaluation
Run your evaluation again to confirm the error is resolved. The packages will now be loaded directly fromnode_modules with proper ESM context.