-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Prerendering causing build error in SvelteKit #9809
Comments
I have the same issue with netlify build.
EDITED: Turns out I had Node version 16 in Netlify. I set Node version 20 and problem solved. Sharing this in case anyone encounters the same problem as I did... |
I'm getting the same error as @WhyAsh5114 when trying to build my project with sveltekit's static adapter. Error persists in Node.js v21.5.0, but I had the same error in Node.js v18.16.0. Reproduce the bug by cloning
|
Hey folks, sorry about this, we've just shipped a little fix in
Also on an unrelated note, you no longer need to explicitly install import Google from "@auth/sveltekit/providers/google"; Working config// /src/auth.ts
import { SvelteKitAuth } from "@auth/sveltekit";
import Google from "@auth/sveltekit/providers/google";
import { AUTH_GOOGLE_ID, AUTH_GOOGLE_SECRET } from "$env/static/private";
export const { handle } = SvelteKitAuth({
basePath: "/auth",
secret: "abc", // Replace with output of `openssl rand -hex 32 | xc` from termianl
providers: [
Google({ clientId: AUTH_GOOGLE_ID, clientSecret: AUTH_GOOGLE_SECRET }),
],
}); // /src/hooks.server.ts
export { handle } from "./auth" Making the above changes got your project ( |
When using this new
I get this new error during build:
What should I do to fix this? |
This is your Something like this: Sorry for the confusion, new docs coming soon. |
There still seems to be an issue here. If I create a latest sveltekit project and use @auth/sveltekit 0.13.0 I get the same error message when building as @WhyAsh5114 with the following code in auth.ts
and hooks.server.ts as follows:
If I comment out the line that sets the session, the error message disappears.
|
issue still persists, even after separating the |
We're looking into it in #10117 if anyone wants to participate there atm |
I can't find the actual part of the SvelteKit code that causes the import of `"$env/dynamic/private"` inside a node_module to fail, but I fixed our example so the problem surfaced. I also discovered sveltejs/kit#12028 which states that a warning should be added that third-party libraries should not use this import. And nextauthjs/next-auth#9809 + nextauthjs/next-auth#10117 which highlight problems when it is used. Perhaps we'll need to explore something like nextauthjs/next-auth#6247 but it seems that `process.env` is populated in SvelteKit so we can use it for now. Fixes #982
Environment
Reproduction URL
https://github.com/WhyAsh5114/authjs-sveltekit-prerender
Describe the issue
Marking a route as prenderable with
export const prerender = true
creates a build error, usable in dev though. Removing the prerender line fixes it.How to reproduce
@auth/sveltekit
and@auth/core
.handle
hook withSvelteKitAuth()
npm run build
.Expected behavior
Build should succeed.
The text was updated successfully, but these errors were encountered: