vercel / ai

Build AI-powered applications with React, Svelte, Vue, and Solid
https://sdk.vercel.ai/docs
Other
10.18k stars 1.53k forks source link

[ERR_REQUIRE_ESM]: require() of ES Module when using AI SDK 4.0 #3794

Closed kevsjh closed 2 days ago

kevsjh commented 2 days ago

Description

Running vercel ai sdk on Firebase function. Upgraded to v4.0 and facing esm issue

Error message below

Error [ERR_REQUIRE_ESM]: require() of ES Module .../node_modules/nanoid/non-secure/index.js from .../node_modules/@ai-sdk/provider-utils/dist/index.js not supported. Instead change the require of .../node_modules/nanoid/non-secure/index.js in .../node_modules/@ai-sdk/provider-utils/dist/index.js to a dynamic import() which is available in all CommonJS modules.

Code example

No response

AI provider

ai": "^4.0.1

Additional context

No response

lgrammel commented 2 days ago

https://github.com/vercel/ai/pull/3795

lgrammel commented 2 days ago

Most likely caused by upgrading nanoid to v5. I've downgraded. Please try using the updated packages when they become available.

https://github.com/vercel/ai/pull/3796

If the issue persists, pls reopen.

kevsjh commented 1 day ago

fixed on 4.0.2, thanks