twentyhq/twenty · error · Error
Missing ${name} env var
Error message
Missing ${name} env var What it means
The partner `seed` script uses the same `requireEnv` pattern as the purge script: it loads `.env.local` (or `ENV_FILE`) via dotenv, then throws when any required variable is unset. The seeder bootstraps demo partners, opportunities, budgets, etc. via the CoreApiClient, so it needs the API URL and key (and any other required values) before it can write. The message is generic on purpose — the interpolated `${name}` identifies which variable is missing.
Source
Thrown at packages/twenty-apps/internal/twenty-partners/src/scripts/seed.ts:22
// 5 statuses (each linked to a partner + opportunity).
//
// Run from this app directory, against a running Twenty server with the app
// installed (deploy first; do NOT run `yarn test` after — its teardown wipes the app).
// Credentials from shell env or a gitignored .env.local (TWENTY_PARTNERS_API_URL/KEY).
//
// yarn twenty dev --once
// tsx src/scripts/seed.ts
import { config } from 'dotenv';
config({ path: process.env.ENV_FILE ?? '.env.local' });
import { CoreApiClient } from 'twenty-client-sdk/core';
import { backfillPartnerUserOnChildren } from 'src/modules/shared/services/backfill-partner-user-on-children.service';
const requireEnv = (name: string): string => {
const value = process.env[name];
if (!value) throw new Error(`Missing ${name} env var`);
return value;
};
const CAL = 'https://calendly.com/placeholder';
const PRIMARY_DEMO_PARTNER_SLUG = 'nine-dots-ventures';
const PRIMARY_DEMO_BUDGET_USD = 15000;
const PRIMARY_DEMO_DESCRIPTION_MARKDOWN = `## About Nine Dots Ventures
Nine Dots helps scaling teams launch Twenty as an operational system of record, not just a CRM.
### What we typically deliver
- Discovery workshops to align sales, operations, and leadership.
- End-to-end pipeline design with custom lifecycle stages.
- Migration plans that preserve historical activities and account context.
- Team onboarding with adoption dashboards and weekly office hours.
### Why clients pick usView on GitHub (pinned to 1f5dd2bbd2)
Solutions
- Run the repo's dev-env setup (`bash packages/twenty-utils/setup-dev-env.sh`) to copy and populate the `.env` files, then re-run the seed.
- Grep the seed script and its imports for every `requireEnv('...')` call and confirm each variable exists in your `.env.local`.
- Pass `ENV_FILE` explicitly if you intend a non-default file, e.g. `ENV_FILE=.env.prod tsx src/scripts/seed.ts`.
- Diff your `.env.local` against `.env.example` to find any newly added required keys.
Example fix
// before
const requireEnv = (name: string): string => {
const value = process.env[name];
if (!value) throw new Error(`Missing ${name} env var`);
return value;
};
// after — collect all missing vars and fail once with the full list
const requireEnv = (name: string): string => {
const value = process.env[name];
if (!value) {
throw new Error(
`Missing ${name} env var (loaded ${process.env.ENV_FILE ?? '.env.local'})`,
);
}
return value;
}; Defensive patterns
Strategy: validation
Validate before calling
const REQUIRED_SEED_ENV = ['CORE_API_URL', 'CORE_API_KEY'] as const;
const missing = REQUIRED_SEED_ENV.filter((k) => !process.env[k]);
if (missing.length) {
throw new Error(
`Missing required env vars for seed: ${missing.join(', ')} (loaded ${process.env.ENV_FILE ?? '.env.local'})`,
);
} Prevention
- Run `setup-dev-env.sh` before the seed so env files are populated.
- Maintain an explicit REQUIRED list at the top of the seed script and validate it first.
- Keep `.env.example` as the source of truth for required keys.
- Pass `ENV_FILE` explicitly per environment.
When it happens
Trigger: Running `tsx src/scripts/seed.ts` (or the `yarn twenty dev --once` flow that invokes it) when the Twenty GraphQL endpoint URL, API key, or another required env var is missing from the loaded env file.
Common situations: New developer setup without running the dev-env setup script that copies `.env` files; switching environments without updating `ENV_FILE`; a recent script change that added a new `requireEnv` call not yet reflected in the team's `.env.example`.
Related errors
- Missing ${name} env var
- Server error (${response.status})
- Missing env var: ${name}
- upsertRowLevelPermissionPredicates returned fewer than 2 pre
- upsertRowLevelPermissionPredicates returned no predicate for
AI-assisted analysis of twentyhq/twenty@1f5dd2bbd2 (2026-08-12).
Data as JSON: /api/errors/ad98302e013f5719.
Report an issue: GitHub.