microsoft/monaco-editor · error · Error
Missing VSCODE_REF in process.env
Error message
Missing VSCODE_REF in process.env
What it means
Thrown by getNightlyEnv() when process.env.VSCODE_REF is falsy. The nightly build uses VSCODE_REF as the git ref (branch/tag/commit) to shallow-clone from the VS Code repository when building monaco-editor-core, so the nightly monaco-editor tracks a specific VS Code revision. Without it the build cannot know which VS Code source to compile, so the guard aborts before any clone. PRERELEASE_VERSION is checked first, so this error only appears once that passes.
Source
Thrown at scripts/ci/env.ts:12
interface Env {
VSCODE_REF: string;
PRERELEASE_VERSION: string;
}
export function getNightlyEnv(): Env {
const env: Env = process.env as any;
if (!env.PRERELEASE_VERSION) {
throw new Error(`Missing PRERELEASE_VERSION in process.env`);
}
if (!env.VSCODE_REF) {
throw new Error(`Missing VSCODE_REF in process.env`);
}
return env;
}
View on GitHub (pinned to ca1b42dc89)
Solutions
- Export VSCODE_REF before running: `VSCODE_REF=main node scripts/ci/build-monaco-editor-core-pkg.ts nightly`.
- In CI, add VSCODE_REF (a branch like `main` or `release/1.x`) to the nightly job's env or secrets.
- Confirm the value is non-empty — empty string is falsy and still throws.
- Pair it with PRERELEASE_VERSION since getNightlyEnv checks both.
Example fix
// before $ PRERELEASE_VERSION=0.34.0-dev.20240101 node scripts/ci/build-monaco-editor-core-pkg.ts nightly // throws: Missing VSCODE_REF in process.env // after $ PRERELEASE_VERSION=0.34.0-dev.20240101 VSCODE_REF=main node scripts/ci/build-monaco-editor-core-pkg.ts nightly
Defensive patterns
Strategy: validation
Validate before calling
if (!process.env.VSCODE_REF) {
console.error('VSCODE_REF (a VS Code git ref) is required for nightly core builds.');
process.exit(2);
}
// then run the nightly core build Type guard
function hasVscodeRef(env: NodeJS.ProcessEnv): env is NodeJS.ProcessEnv & { VSCODE_REF: string } {
return Boolean(env.VSCODE_REF);
} Prevention
- Pair VSCODE_REF with PRERELEASE_VERSION in the same CI env block so one isn't missed.
- Default the ref to a known branch in non-production nightly test runs.
- Add a CI preflight step that prints which env vars are set (names only) for quick diagnosis.
When it happens
Trigger: Running the nightly core build (`build-monaco-editor-core-pkg.ts nightly`) when VSCODE_REF is unset/empty. Most common in CI when the ref variable wasn't wired into the nightly job, or when running the script locally without the var.
Common situations: CI workflow's nightly job missing the VSCODE_REF env injection; the secret renamed (e.g. from VSCODE_BRANCH) without updating the script; running the core nightly build outside the release pipeline; an environment scoping issue where the var exists in `prod` but not the job's environment.
Related errors
- Missing PRERELEASE_VERSION in process.env
- Invalid argument
- Invalid argument
- Cannot merge ${fieldName}: property '${key}' already exists
AI-assisted analysis of microsoft/monaco-editor@ca1b42dc89 (2026-08-13).
Data as JSON: /api/errors/1f78c49a4ad54b8d.
Report an issue: GitHub.