Build error deploying a Svelte project to Prod (Preview builds fine)

error during build:

Error: Could not resolve peer dependency "svelte/compiler" relative to your project — please install it and try again.
at resolve_peer_dependency (file:///vercel/path0/node_modules/@sveltejs/kit/src/utils/import.js:20:10)
at async file:///vercel/path0/node_modules/@sveltejs/kit/src/core/sync/utils.js:7:21
Error: Command "npm run build" exited with 1

Used to work fine. Cannot understand what changed. The AI assistant says the error is unexpected.

It looks like there’s a missing dependency, but I don’t know enough about your project to say why that’s happening. Do you have a public repo or a minimal reproducible example that I can use to help you debug?

Thank you, Amy.

The public repo is at GitHub - elterman/Worded-Well. Preview builds and deploys fine, and the local build runs without an issue as well. The problem is with the Prod build. It started happening today after a totally innocent code change. Thank you for looking into it.

EDIT: Well, now Preview build fails as well, same error.

EDIT2: Seems to be working now. BTW, I created a new project linked to the same repo, deployment worked at first, then stopped working, now it’s working again – in both projects. Go figure.

1 Like

Please let me know if deployments stop working again. I hope they’re all good now!

1 Like

They intermittently fail, especially when run from the CLI (but not only). But I found that if I request “Redeploy” from the website, it usually works.

Having exactly the same problem. It started yesterday. It deploys successfully 2 or 3 times before starting to fail, even without code changes. Deleting the project and recreating it by running vercel on the command line seems to “reset” it, i.e. it deploys successfully 2 or 3 times again, then starts to fail. Just tried again now after 20 or so hours and it again repeated that process - a couple of successful deployments, now failing again. The svelte/compiler dependency cannot be installed manually, it is part of svelte itself.

Hitting the redeploy button in the UI succeeds, which I guess is the workaround for now.

EDIT: Actually, it’s intermittent

elterman & Paul, thanks for the tip about redeploying via the ui. I was able to get a successful build for the first time in days by redeploying.

2 Likes

Do you all get the same Could not resolve peer dependency "svelte/compiler" error every time?

I do get the same error every time.

I was finally able to repro using @elterman’s repo (thanks for sharing it). I could only make it happen on a preview deployment from GitHub. The fact that it tends to work after a redeploy made me think it could be a build cache issue, but it seems to work even if I redeploy with the original build cache :confused:

Tried to disable the build cache anyway, and I couldn’t make the error happen again after that. Tried to re-enable the build cache and got errors again right away. But it doesn’t happen every time so that could just be a coincidence.

Deploying from local with the CLI also didn’t run into errors any of the times I tried it. So possible workarounds include disabling the build cache (add env var VERCEL_FORCE_NO_BUILD_CACHE=1) or using CLI to deploy.

I’m sharing all of this with the internal team so we can dig into the root cause, but I wanted to at least give you a workaround so you don’t keep seeing build errors

1 Like

Thank you, Amy. I just tried to deploy Preview from the CLI, got the error. Haven’t tried disabling the cache yet.

YES. Always same error. And it is still happening frequently, i.e. around 50% of the time for me. Has not once failed on redeploy from UI though.

Will try disable the cache when my too many deploys breach times out :wink:

Thanks Amy! Workaround VERCEL_FORCE_NO_BUILD_CACHE-1 works!

1 Like

Indeed it does. Thank you, Amy.

1 Like