Build folder for deploy is preventing ntl dev running correctly

Site: peppy-rolypoly-dd9af0
Written in: Svelte / Sveltekit 1.0
Info: Sveltekit1.0, Netlify-cli 12.7.2.
Adapter: adapter-netlify
command=“svelte-kit build”
publish = “build”

Issue: If I run ntl dev (ie locally), app is running fine locally. If I run ntl deploy it asks me if I forgot to run build, so i run npm run build and it creates a build folder and I then run ntl deploy and it deploys fine and also runs fine online.

However, if I now want to continue developing locally so I run ntl dev, the app is a complete mess, nothing works, navigation, css - all a mess. BUT … if I DELETE the build folder and run ntl dev, then my app is working fine again locally.

I also tried adapter-auto and that did not work either.
I tried setting the build folder to .svelte-kit but nada.

It appears that sveltekit is now creating a .svelte-kit folder for build. Not sure if that is relevant or not.

Do you know who writes the netlify-adapter - is that Netlify?

Hey @kreollc , I took a look at our help docs about using SvelteKit on Netlify, and I think there are a few things you’ll need to change to get it working as expected. Here’s a link to the docs which explain the optimal config and what build command you should be using: SvelteKit on Netlify | Netlify Docs
Take a look and please let us know if you still have questions there.

Regarding your question about the netlify-adapter, it does look like this is maintained by Svelte: Netlify • Docs • SvelteKit

Thank you. Just read through that. Tried changing build in netlify.toml, reinstalled netlify adapter. App still doing same thing. Have to delete BUILD folder for ntl dev to run the app locally.

Im not too troubled by this as I can delete build folder to work locally.

However, I am fighting a couple of issues. Both possibly related to dotenv. The first was an error telling me dotenv module couldnt be found. I removed the loading of dotenv and set the eny variables up on Netlify and that works. The second issue now running another netlify function is telling me it cant find the jsonwebtoken module. Its installed in the app, is in my package.json. Works fine locally, but not deployed. Any ideas / suggestions welcome.

Update on jsonwebtoken:
I commented out the const jwt=require(‘jsonwebtoken’) and the code that used this to get the token and the remaining code works, so for some reason sveltekit (I assume) is not meshing with jsonwebtoken. Looking for alternatives …

Update and Solution on jsonwebtoken & sveltekit!

These error messages send us on wild-geese chases!! I had the error “cannot locate module jsonwebtoken” several times. It was sort of correct.

I was using

const jwt = require('jsonwebtoken')

After commenting out that and code that used the token, the function worked so I figured there must be some conflict between jsonwebtoken and sveltekit. But I also figured jsonwebtoken is too liked/in use for it not to work.

in between ^ and v I aged a lot, (but matured little).

And then I tried …

import * as jwt from ‘jsonwebtoken’

and just like that, it worked! Hours! Now makes me wonder if the “dotenv” issue was also just “require” instead of “import”. Will revisit and recheck.

But for now, having swicthed back and forth many times, with “require” failing every time and “import” working every time, I rest my case … and my fingers!

I am using Sveltekit 1.0, netlify-cli 12.9.1, using adapter-netlify in svelte.config.js (shown below) and with basic netlify.toml file, shown below and I now have a Sveltekit/Svelte webapp working locally and deployed to Netlify.

Hope this helps someone!

Netlify Support - you can close this request. Thanks.


import adapter from ‘@sveltejs/adapter-netlify’;

/** @type {import(‘@sveltejs/kit’).Config} */

const config = {

kit: {

adapter: adapter()



export default config;


command=“vite build”
publish = “build”

1 Like

Hi @kreollc :wave:t6: , wow that sounds like whirlwind! I’m really glad you got that sorted and we really appreciate you sharing such detailed information with the community. I’m sure it will help others in the future.

1 Like