JulesJ
Convex Community6mo ago
5 replies
Jules

Can't start local development deployment due to missing environment variable

Hi, we would like to get local development deployments working for our repository in order to easily spawn background agents.

Regular development deployments work well, but when I try to run npx convex dev --local --once I get the following error:
$ npx convex dev --local --once                                          
✔ Started running a deployment locally at http://127.0.0.1:3210 and saved its name as CONVEX_DEPLOYMENT to .env.local

Write your Convex functions in convex/
Give us feedback at https://convex.dev/community or support@convex.dev
View the Convex dashboard at https://dashboard.convex.dev/d/<...>

✖ Error: Unable to start push to http://127.0.0.1:3210
✖ Error fetching POST  http://127.0.0.1:3210/api/deploy2/start_push 400 Bad Request: InvalidModules: Hit an error while pushing:
Loading the pushed modules encountered the following
    error:
Uncaught Failed to analyze _deps/node/37HDJG35.js: <ENV_VAR> environment variable is required
    at <anonymous> (../../../../shared/src/sandbox/csb/sdk-patched.ts:22:56)

Looking at this module, the code that's causing this is
if (!process.env.<ENV_VAR>) {
    ...
}

which is located at the root of the module.

This works fine in a cloud deployment, where it's possible to push the code first and after that set the environment variable.

We will look into refactoring the code in order to also make it work with local development deployment, but it would be great if this could work the same as in cloud development deployments.
Was this page helpful?