bun-community / create-templates

48 stars 16 forks source link

error: missing script "main.ts" (Svelte Kit) #16

Open CoreBlender opened 1 year ago

CoreBlender commented 1 year ago

I am a newbie

Screenshot 2023-05-22 171254

image

when I run -> bun run main.ts image

kolchurinvv commented 1 year ago

@CoreBlender, it's not there. bun doesn't fully support svelte-kit, so what you have to do is run the package json scripts that are going to utilise Vite. so to start a dev server run bun run [script_name] (for now). list of scripts in a brand new template:

Screenshot 2023-05-30 at 17 05 55

Good news is that once vite builds it, bun ./build/index.js will actually start the server

natefabian18 commented 1 year ago

Tried looking into using bun with sveltekit ran into an error about Server not being defined. bun run ./build/index.js

Listening on 0.0.0.0:3000
708 | 
709 | function defaultAcceptWebsocket(request, upgrade) {
710 |   return upgrade(request);
711 | }
712 | 
713 | if(server.options.hooks.handleWebsocket) {
      ^
TypeError: undefined is not an object (evaluating 'server.options.hooks')
      at /home/nate/Documents/Git/LeaderBoard/build/index.js:713:3

Happy to provide whatever info I can to assist.

Worth noting that running bun run ./node_modules/.bin/vite dev does appear to work correctly on a surface level. Not sure what its doing under the hood.

kolchurinvv commented 1 year ago

@natefabian18 - i'm guessing you're using the adapter mentioned in the community adapters post. i've had the same issue. there are two options:

  1. go into the build/index.js and edit line 713 to be if (server?.options?.hooks?.handleWebsocket) - less than ideal, since this file is being regenerated on every build.

    1. use https://github.com/gornostay25/svelte-adapter-bun adapter, which seems to have some more traction, however it still uses esbuild instead of bun.build()