© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Cloudflare DevelopersCD
Cloudflare Developers•14mo ago
zachery

SvelteKit private environment variables not exported.

Hello! During when my project is being built, I get errors like this:
src/lib/file.ts (1:9): "PRIVATE_ENVIRONMEN_VARIABLE" is not exported by "virtual:$env/static/private", imported by "src/lib/file.ts"
src/lib/file.ts (1:9): "PRIVATE_ENVIRONMEN_VARIABLE" is not exported by "virtual:$env/static/private", imported by "src/lib/file.ts"

My sveltekit project builds fine locally, maybe because I actually have a .env file. On CF Pages, I set the environment variables in the settings to the same as my local, but it looks like it's not able to find them during the build. I've looked around I saw that people have put the environment variables file into their github repo, but I wanted to ask here if there was another solution. I'm currently don't have an .env in my repo.
Cloudflare Developers banner
Cloudflare DevelopersJoin
Welcome to the official Cloudflare Developers server. Here you can ask for help and stay updated with the latest news
85,042Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

Pages, Sveltekit and Environment variables
Cloudflare DevelopersCDCloudflare Developers / pages-help
2y ago
Environment variables dissappeared ??
Cloudflare DevelopersCDCloudflare Developers / pages-help
11mo ago
Global Environment Variables
Cloudflare DevelopersCDCloudflare Developers / pages-help
3y ago
How do I read environment variables from a SvelteKit website?
Cloudflare DevelopersCDCloudflare Developers / pages-help
15mo ago