[BUG]: Next.js build fails with "Module not found: Can't resolve '@ai-sdk/anthropic'" — only installed @ai-sdk/openai
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/anthropicand@ai-sdk/googleas well), even though we don't use them, or - Add
@learning-commons/evaluatorstoserverExternalPackagesin 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
- Create a Next.js app.
- Install
@learning-commons/evaluatorsand only the OpenAI adapter (@ai-sdk/openai), plusaiandzod. - 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.67ai: 6.0.193zod: 3.25.76- Package manager: pnpm
Additional context
(none)
@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
Fix will be released in v0.8.0, tentatively tomorrow