Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
CoreBlender opened this issue May 22, 2023 · 3 comments
Open

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

CoreBlender opened this issue May 22, 2023 · 3 comments

Comments

@CoreBlender
Copy link

I am a newbie

Screenshot 2023-05-22 171254

image

when I run -> bun run main.ts
image

@kolchurinvv
Copy link

kolchurinvv commented May 30, 2023

@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
Copy link

natefabian18 commented Jul 24, 2023

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
Copy link

kolchurinvv commented Jul 25, 2023

@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.

  2. 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()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants