I’ve looked everywhere for an answer, but no avail, so I assume I might be doing something wrong.
The problem is simple, when I run vercel dev, process.env.VERCEL_GIT_REPO_OWNER is undefined (and other system env listed at System environment variables). This is a system environment variable. Available on deploy, but not locally. Do I need to hardcode it?
The system environment variables you’re referring to, like VERCEL_GIT_REPO_OWNER, are automatically populated by Vercel during deployments . However, these variables are not automatically available when running vercel dev locally. This is because your local development environment doesn’t have the same context as a Vercel deployment. In summary:
System environment variables are primarily intended for use in deployed environments
When running vercel dev, you’re in a local development environment, which doesn’t have access to the same deployment context
Adding these variables to .env.local doesn’t work because they are system-provided variables, not user-defined ones
You could solve this by using a fallback value in your code: