microsoft/monaco-editor · error · Error

Invalid argument

Error message

Invalid argument

What it means

Thrown by the monaco-editor-core release CI script when its single CLI argument is neither 'stable' nor 'nightly'. The script reads process.argv[2] to decide whether to publish a stable build (using the version/vscodeRef from package.json) or a nightly build (computing a prerelease version and reading env vars). Any other value, including undefined from a missing argument, aborts the build. This is a hard guard to prevent publishing an unversioned or misconfigured package.

Source

Thrown at scripts/ci/build-monaco-editor-core-pkg.ts:31

	const monacoEditorPackageJson = require(monacoEditorPackageJsonPath) as {
		version: string;
		vscodeRef: string;
	};
	let version: string;
	let ref: string;

	const arg = process.argv[2];
	if (arg === 'stable') {
		version = monacoEditorPackageJson.version;
		ref = monacoEditorPackageJson.vscodeRef;
	} else if (arg === 'nightly') {
		version = getNightlyVersion(
			monacoEditorPackageJson.version,
			getNightlyEnv().PRERELEASE_VERSION
		);
		ref = getNightlyEnv().VSCODE_REF;
	} else {
		throw new Error('Invalid argument');
	}

	await prepareMonacoEditorCoreRelease(version, ref);

	// npm package is now in dependencies/vscode/out-monaco-editor-core, ready to be published
}

async function prepareMonacoEditorCoreRelease(version: string, vscodeRef: string) {
	await rm(dependenciesPath, { force: true, recursive: true });

	let vscodeCommitId: string;

	await group('Checkout vscode', async () => {
		const result = await gitShallowClone(
			vscodePath,
			'https://github.com/microsoft/vscode.git',
			vscodeRef
		);

View on GitHub (pinned to ca1b42dc89)

Solutions

  1. Invoke the script with exactly one of: `node scripts/ci/build-monaco-editor-core-pkg.ts stable` or `... nightly`.
  2. If calling via npm/pnpm, append the channel after `--`: `npm run <script> -- stable`.
  3. In CI, ensure the job sets the argument from a known enum (e.g. `${{ matrix.channel }}` where channel ∈ {stable, nightly}) and fails the job config early if empty.
  4. Double-check spelling and casing — the comparison is strict equality against lowercase 'stable'/'nightly'.

Example fix

// before
$ node scripts/ci/build-monaco-editor-core-pkg.ts
// after
$ node scripts/ci/build-monaco-editor-core-pkg.ts stable
Defensive patterns

Strategy: validation

Validate before calling

// validate argv before invoking the build
const arg = process.argv[2];
if (arg !== 'stable' && arg !== 'nightly') {
  console.error(`Usage: node scripts/ci/build-monaco-editor-core-pkg.ts <stable|nightly>`);
  process.exit(2);
}
// only then run the script

Type guard

function isReleaseChannel(arg: string | undefined): arg is 'stable' | 'nightly' {
  return arg === 'stable' || arg === 'nightly';
}

Prevention

When it happens

Trigger: Running `node scripts/ci/build-monaco-editor-core-pkg.ts` with no argument, with a typo like 'nigthly' or 'Stable' (case-sensitive), or with an extra/positional argument that shifts argv[2]. Also triggered by invoking the script through a wrapper that forgets to forward the release kind.

Common situations: Local developer running the release script manually to test it; a CI pipeline whose job matrix passes the channel via a variable that resolved to empty; refactoring the script and forgetting the argument; copy-pasting the npm script without the trailing `-- stable`/`-- nightly`.

Related errors


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