Search code examples
javascriptsveltesapper

Sapper export failing without server


I am using Sapper with Svelte to create a static website.

Because my website is static, I won't be bothering with a server and will use the sapper export command to generate static files which I can host on GitLab pages.

I have therefore removed the server.js file in my src directory - it shouldn't be necessary. However, when I run the export command, it fails with the following error:

Error: could not resolve entry module (src\server.js)

Why is this looking for a server and how to I fix this?

I also tried removing the server option in rollup.config.js, however this now complains that the client, server and serviceworker properties are required.


Solution

  • When you run sapper export, it creates the static build by running your server and crawling your site. For that reason, you do need server.js. (This might change in a future version.)