Netlify Dev Breaks Locally After Build

I have a SvelteKit site with the Netlify adapter installed. The site builds & deploys fine. But after I run npm run build locally, netlify dev starts having issues. It gives me a site that can’t find any generated js or css. The issue only exists with the site as served on the Netlify port (8888). When I run netlify dev, the underlying site at the SvelteKit dev port (5173) works fine.

If I delete the build folder that was generated during the build, netlify dev goes back to working normally. I don’t need to delete the files that were generated in the .netlify folder for it to start working again.

If I try to do netlify serve, I get the following error:
Error: ENOENT: no such file or directory, lstat ‘[base path].netlify\functions-serve.unzipped\sveltekit-render\sveltekit-render.js’

There is sveltekit-render.mjs in that folder, but not a .js.

Any ideas why building the site breaks netlify dev or why netlify serve isn’t working?


Hi @bcrotty :wave:t6: welcome to the forums thanks so much for reaching out! This could be related to the way SvelteKit generates and handles files during the build process. It seems that the build process is creating files with a .mjs extension instead of the expected .js extension, which might be causing compatibility issues with Netlify’s expectations. It would be great if you shared your site name or link to your site.