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

  1. Export VSCODE_REF before running: `VSCODE_REF=main node scripts/ci/build-monaco-editor-core-pkg.ts nightly`.
  2. In CI, add VSCODE_REF (a branch like `main` or `release/1.x`) to the nightly job's env or secrets.
  3. Confirm the value is non-empty — empty string is falsy and still throws.
  4. 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

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


AI-assisted analysis of microsoft/monaco-editor@ca1b42dc89 (2026-08-13). Data as JSON: /api/errors/1f78c49a4ad54b8d. Report an issue: GitHub.