#"window is not defined" build error

5 messages · Page 1 of 1 (latest)

elder furnace
#

I am trying to build my application for windows. It works fine on linux (compiles and runs just fine) but on windows the dev command exits with code 255 and when I try to build the app it gives me an error: "window is not defined". I am using Sveltekit for the frontend
This is the function that the error seems to originate from:

export async function authenticateWithTwitch() {
    const response = await invoke('authenticate_with_twitch');
    return accessTokenResponseSchema.parse(response);
}
#

the build error:

ReferenceError: window is not defined
    at invoke (file:///E:/coding/game-chronicle/node_modules/@tauri-apps/api/core.js:118:5)
    at authenticateWithTwitch (file:///E:/coding/game-chronicle/.svelte-kit/output/server/chunks/igdb.js:21:26)
    at load (file:///E:/coding/game-chronicle/.svelte-kit/output/server/entries/pages/_page.ts.js:5:37)
    at load_data (file:///E:/coding/game-chronicle/.svelte-kit/output/server/index.js:647:44)
    at async file:///E:/coding/game-chronicle/.svelte-kit/output/server/index.js:1984:18

node:internal/event_target:1016
  process.nextTick(() => { throw err; });
                           ^
Error: 500 /
To suppress or handle this error, implement `handleHttpError` in https://kit.svelte.dev/docs/configuration#prerender
    at file:///E:/coding/game-chronicle/node_modules/@sveltejs/kit/src/core/config/options.js:212:13
    at file:///E:/coding/game-chronicle/node_modules/@sveltejs/kit/src/core/postbuild/prerender.js:64:25
    at save (file:///E:/coding/game-chronicle/node_modules/@sveltejs/kit/src/core/postbuild/prerender.js:403:4)
    at visit (file:///E:/coding/game-chronicle/node_modules/@sveltejs/kit/src/core/postbuild/prerender.js:236:3)
Emitted 'error' event on Worker instance at:
    at [kOnErrorMessage] (node:internal/worker:300:10)
    at [kOnMessage] (node:internal/worker:311:37)
    at MessagePort.<anonymous> (node:internal/worker:212:57)
    at [nodejs.internal.kHybridDispatch] (node:internal/event_target:741:20)
    at exports.emitMessage (node:internal/per_context/messageport:23:28)

Node.js v18.17.1
error: script "build" exited with code 1
    Error beforeBuildCommand `bun run build` failed with exit code 1
#

From what I understand, window is not defined usually means that something is being executed server-side and the client hasn't loaded yet, but I have disabled SSR and I don't understand how that would be the case for one operating system but not the other

placid summit
#

I have no explanation for the os diffs though