Sveltekit: Could not resolve peer dependency relative to your project

Every day I get the following error.

> vite build
▲ [WARNING] Cannot find base config file "./.svelte-kit/tsconfig.json" [tsconfig.json]
    jsconfig.json:2:12:
      2 │   "extends": "./.svelte-kit/tsconfig.json",
        ╵              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
failed to load config from /vercel/path0/vite.config.js
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

To bypass this issue, I have to manually run the following command in the CLI:

vercel --force --prod

However, unless I do this, any automatic deployments triggered by pushing to GitHub will continue to fail with the same error.

Here’s my package.json:

{
	"name": "redacted",
	"private": true,
	"version": "0.0.1",
	"type": "module",
	"scripts": {
		"dev": "vite dev",
		"build": "vite build",
		"preview": "vite preview",
		"prepare": "svelte-kit sync || echo ''",
		"format": "prettier --write .",
		"lint": "prettier --check . && eslint ."
	},
	"devDependencies": {
		"@eslint/compat": "^1.2.5",
		"@eslint/js": "^9.18.0",
		"@sveltejs/adapter-auto": "^4.0.0",
		"@sveltejs/adapter-vercel": "^5.6.3",
		"@sveltejs/kit": "^2.19.1",
		"@sveltejs/vite-plugin-svelte": "^5.0.0",
		"autoprefixer": "^10.4.20",
		"eslint": "^9.18.0",
		"eslint-config-prettier": "^10.0.1",
		"eslint-plugin-svelte": "^2.46.1",
		"globals": "^15.14.0",
		"prettier": "^3.4.2",
		"prettier-plugin-svelte": "^3.3.3",
		"prettier-plugin-tailwindcss": "^0.6.10",
		"svelte": "^5.23.0",
		"tailwindcss": "^3.4.17",
		"vite": "^6.0.0"
	},
	"engines": {
		"node": "22.x"
	}
}

Hi @datio, welcome to the Vercel Community!

Sorry that you’re facing this issue. But, I wasn’t able to reproduce it on my new project created with sveltekit GitHub - Anshuman71/example-sveltekit

If you need more help, please share your public repo or a minimal reproducible example. That will let us all work together from the same code to figure out what’s going wrong.

1 Like