vercel / ai

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

Vercel build breaking because of Svelte 4.0 optional peer dependency #248

Closed jerriclynsjohn closed 1 year ago

jerriclynsjohn commented 1 year ago

Build breaks at the installation of the package itself, here are the logs from Vercel

npm ERR! code ERESOLVE
--
16:24:03.809 | npm ERR! ERESOLVE could not resolve
16:24:03.809 | npm ERR!
16:24:03.809 | npm ERR! While resolving: ai@2.1.10
16:24:03.809 | npm ERR! Found: svelte@3.59.2
16:24:03.809 | npm ERR! node_modules/svelte
16:24:03.810 | npm ERR!   peer svelte@"^3.29.0" from sswr@1.10.0
16:24:03.810 | npm ERR!   node_modules/sswr
16:24:03.810 | npm ERR!     sswr@"^1.10.0" from ai@2.1.10
16:24:03.810 | npm ERR!     node_modules/ai
16:24:03.810 | npm ERR!       ai@"^2.1.10" from the root project
16:24:03.810 | npm ERR!
16:24:03.810 | npm ERR! Could not resolve dependency:
16:24:03.810 | npm ERR! peerOptional svelte@"^4.0.0" from ai@2.1.10
16:24:03.810 | npm ERR! node_modules/ai
16:24:03.810 | npm ERR!   ai@"^2.1.10" from the root project
16:24:03.810 | npm ERR!
16:24:03.810 | npm ERR! Conflicting peer dependency: svelte@4.0.1
16:24:03.811 | npm ERR! node_modules/svelte
16:24:03.811 | npm ERR!   peerOptional svelte@"^4.0.0" from ai@2.1.10
16:24:03.811 | npm ERR!   node_modules/ai
16:24:03.811 | npm ERR!     ai@"^2.1.10" from the root project
16:24:03.811 | npm ERR!
16:24:03.811 | npm ERR! Fix the upstream dependency conflict, or retry
16:24:03.811 | npm ERR! this command with --force or --legacy-peer-deps
16:24:03.811 | npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
16:24:03.811 | npm ERR!
16:24:03.811 | npm ERR!
16:24:03.811 | npm ERR! For a full report see:
16:24:03.811 | npm ERR! /vercel/.npm/_logs/2023-06-29T10_54_02_982Z-eresolve-report.txt
16:24:03.812 |  
16:24:03.812 | npm ERR! A complete log of this run can be found in:
16:24:03.812 | npm ERR!     /vercel/.npm/_logs/2023-06-29T10_54_02_982Z-debug-0.log
16:24:03.828 | Error: Command "npm install" exited with 1
16:24:04.181 | BUILD_UTILS_SPAWN_1: Command "npm install" exited with 1

Repo to reproduce the error: https://github.com/tierrun/tier-vercel-openai

I'm able to make it work using npm i -f

pbizimis commented 1 year ago

Having the same issue

rockstox commented 1 year ago

if you're deploying to vercel, override the install step with this npm i -f to get it working.. for now

morganhvidt commented 1 year ago

I'm also experincing this during builds. My project that doesn't use Svelte.

brerdem commented 1 year ago

Does anybody have a solution for this? Whenever I add a new package I got this error and the package won't install. I'm using ^2.1.13 and tried npm i -f too

fjaskolski commented 1 year ago

With npm i -f I can make it work locally, but not when deploying with Vercel. Overriding the install command doesn't help:

Screen Shot 2023-07-02 at 17 25 07

From what I see in the Vercel deploy logs, there are two rounds of npm installs—the first one uses the overridden command with -f flag and goes through, but the second one uses plain npm install and fails.

Screen Shot 2023-07-02 at 17 12 56
fjaskolski commented 1 year ago

FYI: Just tested that yarn lets this one slide. If you're in a hurry, switching to yarn should do.

heyaware commented 1 year ago

Seeing the same issue since v2.1.10. NextJS app, but seeing svelte related errors.

kitchenbeats commented 1 year ago

Same. Any version after 2.1.9 gives me this error. If i force, it installs but does not stream.

jerriclynsjohn commented 1 year ago

er 2.1.9 gives me this error. If i force, it installs but does not stream.

With npm i -f I can make it work locally, but not when deploying with Vercel. Overriding the install command doesn't help:

Screen Shot 2023-07-02 at 17 25 07

From what I see in the Vercel deploy logs, there are two rounds of npm installs—the first one uses the overridden command with -f flag and goes through, but the second one uses plain npm install and fails.

Screen Shot 2023-07-02 at 17 12 56

Your command should've been npm install --force or npm i -f instead of npm i -force.

morganhvidt commented 1 year ago

I switched to yarn quickly. It's a workaround in the meanwhile.

  1. Delete the node_modules folder.
  2. Delete the package-lock.json.
  3. Install Yarn globally (my preference) npm install --global yarn
  4. Run yarn install to reinstall.
  5. You can override the install settings in the vercel dashboard with yarn install.
  6. 🥳 Celebrate and wonder if you'll continue to use yarn after the fix has been made.
MaxLeiter commented 1 year ago

I believe this is a bug with npm and not respecting the optional peer dependencies fields. I've pushed a temporary fix that should resolve this, but I recommend you use pnpm.

chunyulo-code commented 1 year ago

5. vercel

I did using yarn instead of npm, it can pass the building phase, but when I request to steaming methods, it shows the error message at my console: Failed to load resource: the server responded with a status of 405 () and 926-d92de8ec4d18b2f9.js:15 Uncaught (in promise) Error: Failed to fetch the chat response.

MichaelReaNZ commented 1 year ago

I got this issue to and I don't use svelte

chunyulo-code commented 1 year ago

I got this issue to and I don't use svelte

Could you please provide a clearer explanation of how you solve this problem without using Svelte?

MichaelReaNZ commented 1 year ago

I got this issue to and I don't use svelte

Could you please provide a clearer explanation of how you solve this problem without using Svelte?

I don't know how to solve it, I'm just using next only.

chunyulo-code commented 1 year ago

I just solved this issue.

Following the suggestion up there, using yarn install instead of npm..., then it works!