You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
The following Vite config options will be overridden by SvelteKit: root #13376
This warning pops up when running vitest on Windows. It seems like the config() function of the Kit Vite plugin runs multiple times, and that paths are normalized (possibly since Vite 6?). The warning comes from this line:
So, the 2 configs have the same path, but one with forward slashes, and one with backslashes.
SvelteKit itself tries to set config.root to the version with backslashes, as it uses process.cwd() to get it. Maybe it should use posixify() on it before? Replacing this line:
If anyone is interested, I got AI to write a patch script to help with this until it's fixed.
Added this to package.json
"scripts": {
"postinstall": "node ./scripts/patch-script.js"
}
and created this file.
#!/usr/bin/env node
// This will be deleted when Svelte releases this fix https://github.com/sveltejs/kit/issues/13376importfsfrom'fs';importpathfrom'path';import{fileURLToPath}from'url';// Get current directoryconst__filename=fileURLToPath(import.meta.url);const__dirname=path.dirname(__filename);// Path to the file we need to modifyconstfilePath=path.join(process.cwd(),'node_modules','@sveltejs','kit','src','exports','vite','index.js');console.log(`Checking for SvelteKit file at: ${filePath}`);// Check if the file existsif(!fs.existsSync(filePath)){console.log('SvelteKit file not found. The patch was not applied.');process.exit(0);}// Read the fileletcontent=fs.readFileSync(filePath,'utf8');// Look for the line we need to changeconstsearchString='root: cwd,';constreplaceString='root: posixify(cwd),';// Check if the file already contains the fixif(content.includes(replaceString)){console.log('The SvelteKit file is already patched.');process.exit(0);}// Check if the line to change existsif(!content.includes(searchString)){console.log('The line to patch was not found. Structure may have changed. Please check manually.');process.exit(1);}// Apply the changeconstpatchedContent=content.replace(searchString,replaceString);// Write the file backfs.writeFileSync(filePath,patchedContent,'utf8');console.log('Successfully patched SvelteKit vite/index.js to use posixify(cwd).');
Reacted by Samuele Esposito, It's Me!, Garrett Smith and Patrick Joannisse
The following Vite config options will be overridden by SvelteKit:
- base
since upgrading to Vitest 4. Possibly related.
Reacted by Brandon Pittman, Matheus Ferraz, tamas-torjek, theconektd, Jason L Perry, Garrett Smith, Caleb Evans, Matthew, David Dal Busco, Samuel Huang and 4 more
The following Vite config options will be overridden by SvelteKit:
- base
since upgrading to Vitest 5. Possibly related.
Looking into this issue, it appears that Vitest >=4 sets the base path to '/' by default, which is not acceptable according to the SvelteKit docs which say:
A root-relative path that must start, but not end with / (e.g. /base-path), unless it is the empty string...
I realized this by simply appending these lines right after the console.error from the warn_overridden_config API:
Activity
damiensawyer commentedon Apr 13, 2025
If anyone is interested, I got AI to write a patch script to help with this until it's fixed.
Added this to package.json
"scripts": {
"postinstall": "node ./scripts/patch-script.js"
}
and created this file.
rebasecase commentedon Aug 12, 2025
niemyjski commentedon Sep 21, 2025
I'm also seeing this with storybook
tylergannon commentedon Oct 25, 2025
macOS too with latest tooling.
package.json
thunze commentedon Oct 31, 2025
Seeing
since upgrading to Vitest 4. Possibly related.
peterpeterparker commentedon Nov 21, 2025
- baseis popping as well in my projects when I migrate from vitest v3 to v4.huangsam commentedon Nov 26, 2025
Looking into this issue, it appears that Vitest >=4 sets the base path to
'/'by default, which is not acceptable according to the SvelteKit docs which say:I realized this by simply appending these lines right after the
console.errorfrom thewarn_overridden_configAPI:I foresee a few options, in case that helps future maintainers or users who stumble upon this issue:
basekeyvitestunder 4.x for our specific projectslewisacidic commentedon Dec 16, 2025
An simple hack for the base issue is to reset base to '' in a plugin that runs before sveltekit. A super minimal
vite.config.tsmight look like:This stops the annoying bold red message.