Configuring an output directory in a Svelte project with sapper

Viewed 2359

I am getting an error, *Error: No output directory named "export" found.*, using Now with a SvelteJS project and Sapper. I have tried to find info on how I can add the folder to my package.json file but have come up empty. (Still learning how it all works. In the Now docs, I get this: To resolve this error, configure your project to place its static output files into a public directory, at the root of your project, when the build script from your package.json file is invoked.

I have tried:

 {
 "scripts": {
 "build": "sapper build --output export"
 }
 }

but no luck. Would appreciate a bit of help in getting this to work.

4 Answers

Finally figured it out:

"build": "sapper export"

Actually when you build, no export folder is there. When you try to access it in starting the production server, the it looks for it. When not found the error is thrown.

To remove it, you can replace

"build": "sapper build --legacy",

in package.json with

"build":"sapper export"

Try this:

{
  "scripts": {
    "build": "sapper export && mv ./__sapper__/export ./public"
  }
}

It's clean, it only happens on now servers (unless you run yarn build locally), and it will give a statically generated site that doesn't require the now-sapper builder or any kind of continuously running serve command.

Maybe you can try with this command:

npx sapper export

folder build on __sapper __/export

Related