slint-ui/slint · error · Error

unknown command

Error message

unknown command: ${command}

What it means

packaging.mts is a command-dispatch CLI: main() switches on the first CLI argument and each case handles one packaging subcommand (pack, pack-dev-meta, publish-all, ...). This Error is the default branch — a generic guard saying the subcommand name given on the command line matches no known handler, usually a typo or an invocation of the script with no/incorrect arguments.

Solutions

  1. Use one of the supported commands (e.g. publish-all) exactly as spelled.
  2. Inspect the switch statement in packaging.mts main() to list valid commands.
  3. Fix automation scripts to use the current command names.

Example fix

// before
node packaging.mts publish --dir dist
// after
node packaging.mts publish-all dist
Defensive patterns

Strategy: validation

Validate before calling

const VALID = ['publish-all'];
if (!VALID.includes(command)) throw new Error(`unknown command: ${command}`);

Try / catch

main(process.argv.slice(2)).catch((e) => {
  console.error(e.message);
  process.exitCode = 1;
});

Prevention

When it happens

Trigger: Running the script with an unrecognized first argument, e.g. `node packaging.mts publlish-all ...`.

Common situations: Typo in the subcommand, following outdated docs, scripting the tool with a command removed in a newer version.

Understand the failure class

Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.

Related errors


AI-assisted analysis of slint-ui/slint@bb937076de (2026-09-16). Data as JSON: /api/errors/a77c6cd5b3fff311. Report an issue: GitHub.

Appendix: source

Thrown at api/node/scripts/packaging.mts:253

            });
            break;
        }
        case "pack-dev-meta": {
            const [version, dest, ...targets] = args;
            await packDevMeta({
                version,
                dest,
                targets: targets.length ? targets : undefined,
            });
            break;
        }
        case "publish-all": {
            const [dir, registry, tag] = args;
            await publishAll({ dir, registry, tag: tag || undefined });
            break;
        }
        default:
            throw new Error(`unknown command: ${command}`);
    }
}

// Run as a CLI when executed directly (rather than imported).
if (process.argv[1] && fileURLToPath(import.meta.url) === process.argv[1]) {
    main(process.argv.slice(2)).catch((error) => {
        console.error(error);
        process.exit(1);
    });
}

View on GitHub (pinned to bb937076de)