evaluators icon indicating copy to clipboard operation
evaluators copied to clipboard

[BUG]: Next.js build fails with "Module not found: Can't resolve '@ai-sdk/anthropic'" — only installed @ai-sdk/openai

Open Cogito-Ergo-Video opened this issue 5 months ago • 2 comments

Describe the bug

We're using the evaluators SDK in a Next.js app and we only use OpenAI as our model provider, so I only installed @ai-sdk/openai. When I run the app in Next development, the build fails with:

Module not found: Can't resolve '@ai-sdk/anthropic'
Module not found: Can't resolve '@ai-sdk/google'

It seems like the SDK expects all of the provider packages to be present even though I'm only using one. The only ways I've found to get past it are:

  • Install all three (@ai-sdk/anthropic and @ai-sdk/google as well), even though we don't use them, or
  • Add @learning-commons/evaluators to serverExternalPackages in my Next config — but that doesn't really seem correct and I'm not sure it's the right thing to do.

Ideally we'd only need to install the provider we're actually using.

List steps to reproduce the issue

  1. Create a Next.js app.
  2. Install @learning-commons/evaluators and only the OpenAI adapter (@ai-sdk/openai), plus ai and zod.
  3. Use the SDK with an OpenAI model override:    ```ts    import {      type BaseEvaluatorConfig,      LogLevel,      Provider,    } from "@learning-commons/evaluators";

   const learningCommonsConfig: BaseEvaluatorConfig = {      openaiApiKey: process.env.OPENAI_API_KEY,      modelOverride: {        provider: Provider.OpenAI,        model: "gpt-4o-mini",      },      telemetry: false,      logLevel: LogLevel.SILENT,    };

   const evaluator = new VocabularyEvaluator(learningCommonsConfig);    const result = await evaluator.evaluate(text, "8");    ``` 4. Run the app / build it with Next. 5. The build fails with Module not found: Can't resolve '@ai-sdk/anthropic' and @ai-sdk/google.

Expected behavior

I should only need to install the provider adapter we actually use (@ai-sdk/openai). The app should build without requiring @ai-sdk/anthropic or @ai-sdk/google, and without having to add the package to serverExternalPackages.

Environment (please complete the following):

  • Node: 24.x
  • Next.js: 16.2.6
  • React: 19.2.6
  • @learning-commons/evaluators: 0.6.0
  • @ai-sdk/openai: 3.0.67
  • ai: 6.0.193
  • zod: 3.25.76
  • Package manager: pnpm

Additional context

(none)

Cogito-Ergo-Video avatar Jun 19 '26 18:06 Cogito-Ergo-Video

@Cogito-Ergo-Video - Thank you for reporting this issue. I have a fix up for review, and will update once this is available in our next TypeScript SDK release

adnanrhussain avatar Jun 23 '26 21:06 adnanrhussain

Fix will be released in v0.8.0, tentatively tomorrow

adnanrhussain avatar Jun 29 '26 18:06 adnanrhussain