← All fixes
Vite: import.meta.env.MY_KEY is undefined (env var needs the VITE_ prefix)
#120Error
import.meta.env.API_URL is undefined
Why it happens, and why this works
Vite only exposes variables that start with VITE_ to browser code, so server secrets aren't leaked by accident. Also, .env changes are only read when the dev server starts, and process.env doesn't exist in Vite client code.
Fix
Rename it to VITE_API_URL in .env, read it as import.meta.env.VITE_API_URL, and restart npm run dev. On Vercel/Netlify add the same VITE_ name in the project settings and redeploy (values are baked in at build time). Never put a secret key in a VITE_ variable: everything VITE_ ships to the browser.
Did it work?
No reports yet0 worked0 didn't
Tried it yourself?
Related fixes
ImportError: cannot import name from partially initialized module (circular import)
#52ImportError: cannot import name 'User' from partially initialized module 'models' (most likely due to a circular import). Python 3.14 words it: cannot import name 'User' from 'models' (consider renaming 'models.py' if it has the same name as a library you intended to import)
pythonVerifiedNo reports yet
Importing a JSON file in ESM fails: needs an import attribute of type json
#26TypeError [ERR_IMPORT_ATTRIBUTE_MISSING]: Module "file:///app/config.json" needs an import attribute of "type: json"
nodeVerifiedNo reports yet
TS1484: 'User' is a type and must be imported using a type-only import when 'verbatimModuleSyntax' is enabled
#91error TS1484: 'User' is a type and must be imported using a type-only import when 'verbatimModuleSyntax' is enabled.
typescriptviteVerifiedNo reports yet