-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
SvelteKit 2: Builds fail - Cannot read values from $env/dynamic/private while prerendering (attempted to read env.DATABASE_URL). Use $env/static/private instead #11371
Comments
See: It does become quite inconvenient to have to prevent any references to it while building, I hope that can be changed. |
Thanks again, @CaptainCodeman. Those links confirmed this was an intentional change and your workaround helped me. My app doesn't do pre-rendering (disabled in +layout.server.ts) and this put me off course. I didn't even consider that the hooks.server.ts because my inaccurate thinking about pre-rendering didn't see hooks as having a role at build time. Your solution involving I looked everywhere there might be pre-rendering but not in the hooks. Perhaps the documentation on prerendering could mention the role of hooks even when prerendering is otherwise disabled? |
The reproduction doesn't work - it appears github.com/nstuyvesant/shy-svelte has been deleted #11436 was related to improving similar issues. I'm unsure if there's anything left to do here. If folks are still having issues, can someone post a new reproduction? |
I should have some projects with workarounds I can revert, to confirm. |
Hi @benmccann - sorry - that one was made private but sounds like @CaptainCodeman will share. |
If you could make it public again that would speed things up |
@benmccann - done! |
That repository is completely impossible to build. If you copy Or if @CaptainCodeman can share an example that would be helpful as well |
Is anyone able to provide a minimal reproduction for this issue? If not, I will close it |
IMO this works https://github.com/CaptainCodeman/sk-11371 build & preview shows (changing import to private shows all the env values set) |
Thank you for confirming! |
Describe the bug
Got my project migrated to SvelteKit 2.0 but am now getting this error at the end of the build process...
The module that uses this private env value is:
It is only called by +server.ts files in my routes.3 All pages with load functions have
export const prerender = false
.Reproduction
https://stackblitz.com/~/github.com/nstuyvesant/shy-svelte
yarn build
Error will appear.
Logs
See above
System Info
Severity
blocking an upgrade
Additional Information
Build only appears to fail on pre-rendering.
The top-level +layout.server.ts (as do almost all pages) has...
The text was updated successfully, but these errors were encountered: