microsoft/monaco-editor · error · Error
Invalid argument
Error message
Invalid argument
What it means
Thrown by the monaco-editor (wrapper) release CI script when its CLI argument is neither 'stable' nor 'nightly'. Identical guard to the core script but for the consumer-facing monaco-editor package: 'stable' uses package.json's version directly, 'nightly' computes a prerelease version via getNightlyVersion and reads PRERELEASE_VERSION from env. Any other argv[2] value aborts before modifying package.json or running the build/test/package/smoketest pipeline.
Source
Thrown at scripts/ci/build-monaco-editor-pkg.ts:32
);
async function prepareMonacoEditorReleaseStableOrNightly() {
const monacoEditorPackageJson = JSON.parse(
await readFile(monacoEditorPackageJsonPath, { encoding: 'utf-8' })
) as PackageJson;
let version: string;
const arg = process.argv[2];
if (arg === 'stable') {
version = monacoEditorPackageJson.version;
} else if (arg === 'nightly') {
version = getNightlyVersion(
monacoEditorPackageJson.version,
getNightlyEnv().PRERELEASE_VERSION
);
} else {
throw new Error('Invalid argument');
}
await prepareMonacoEditorRelease(version);
// npm package is now in ./out/monaco-editor, ready to be published
}
async function prepareMonacoEditorRelease(monacoEditorCoreVersion: string) {
await group('npm ci', async () => {
await run('npm ci', { cwd: resolve(rootPath, 'webpack-plugin') });
});
await group('Set Version & Update monaco-editor-core Version', async () => {
const packageJson = JSON.parse(await readFile(monacoEditorPackageJsonPath, { encoding: 'utf-8' })) as PackageJson;
packageJson.version = monacoEditorCoreVersion;
packageJson.devDependencies['monaco-editor-core'] = monacoEditorCoreVersion;
await writeJsonFile(monacoEditorPackageJsonPath, packageJson);
});View on GitHub (pinned to ca1b42dc89)
Solutions
- Run with exactly one positional argument: `node scripts/ci/build-monaco-editor-pkg.ts stable` or `... nightly`.
- When using npm run, pass the channel after `--`: `npm run build-monaco-editor-pkg -- nightly`.
- In CI, validate the channel variable is non-empty and one of the two allowed values before invoking the script.
- Check for casing/whitespace — the check is strict equality on lowercase strings.
Example fix
// before $ node scripts/ci/build-monaco-editor-pkg.ts // after $ node scripts/ci/build-monaco-editor-pkg.ts nightly
Defensive patterns
Strategy: validation
Validate before calling
const arg = process.argv[2];
if (arg !== 'stable' && arg !== 'nightly') {
console.error('Usage: node scripts/ci/build-monaco-editor-pkg.ts <stable|nightly>');
process.exit(2);
}
// proceed Type guard
function isReleaseChannel(arg: string | undefined): arg is 'stable' | 'nightly' {
return arg === 'stable' || arg === 'nightly';
} Prevention
- Define npm scripts (e.g. `release:stable`, `release:nightly`) that pass the channel for you, removing the chance of a missing arg.
- In CI, fail the job config early if the channel variable is empty rather than letting the script throw.
- Keep the two release scripts' argv contracts identical so tooling can target either.
When it happens
Trigger: Running `node scripts/ci/build-monaco-editor-pkg.ts` without an argument or with a value other than 'stable'/'nightly'; a CI workflow that conditionally sets the channel and the condition evaluated to undefined; invoking through a runner that drops positional args.
Common situations: Developer testing the packaging flow locally; CI matrix variable not propagated; typo in the channel name; refactoring npm scripts and losing the `-- stable`/`-- nightly` suffix.
Related errors
- Invalid argument
- Cannot merge ${fieldName}: property '${key}' already exists
- Missing PRERELEASE_VERSION in process.env
- Missing VSCODE_REF in process.env
AI-assisted analysis of microsoft/monaco-editor@ca1b42dc89 (2026-08-13).
Data as JSON: /api/errors/85b4b7a2ae0671f0.
Report an issue: GitHub.