denoland/deno · info · ERR_MISSING_ARGS
ERR_MISSING_ARGS
ERR_MISSING_ARGS
Error message
The "file" argument must be specified
What it means
The REPL dot-command `.save` writes every line evaluated in the current session to a file. It requires a filename argument; when invoked with none (`file === ''`) it throws ERR_MISSING_ARGS, which the command's own catch block converts into the printed line 'The "file" argument must be specified' before re-displaying the prompt. The error never escapes to the session.
Source
Thrown at ext/node/polyfills/repl.ts:474
longestNameLength - name.length + 3,
);
const line = `.${name}${cmd.help ? spaces + cmd.help : ""}\n`;
this.output.write(line);
});
this.output.write(
"\nPress Ctrl+C to abort current expression, " +
"Ctrl+D to exit the REPL\n",
);
this.displayPrompt();
},
});
repl.defineCommand("save", {
help: "Save all evaluated commands in this REPL session to a file",
action: function (this: REPLServer, file: string) {
try {
if (file === "") {
throw new ERR_MISSING_ARGS("file");
}
fs.writeFileSync(file, ArrayPrototypeJoin(this.lines, "\n"));
this.output.write(`Session saved to: ${file}\n`);
} catch (error) {
if ((error as { code?: string })?.code === "ERR_MISSING_ARGS") {
this.output.write(`${(error as Error).message}\n`);
} else {
this.output.write(`Failed to save: ${file}\n`);
}
}
this.displayPrompt();
},
});
repl.defineCommand("load", {
help: "Load JS from a file into the REPL session",
action: function (this: REPLServer, file: string) {
try {View on GitHub (pinned to 9ad36f7a2c)
Solutions
- Type the command with a path: `.save /tmp/session.js`
- Check the syntax — the filename follows the command separated by a space, e.g. `.save session.log`
Example fix
// before deno> .save The "file" argument must be specified // after deno> .save session.js Session saved to: session.js
Defensive patterns
Strategy: validation
Validate before calling
// programmatic REPL driver: check the filename before sending .save
const file = process.argv[2];
if (!file) {
console.error('usage: .save <file>');
} else {
replServer.write(`.save ${file}\n`);
} Prevention
- Always append a filename after .save
- Use absolute paths so the session file lands where you expect
When it happens
Trigger: Typing `.save` with no filename (the REPL trims the rest of the line to an empty string) in a `deno` or node:repl session.
Common situations: Users expecting `.save` alone to pick a default file (like shell history tools); typos such as `.save>`; scripted/programmatic REPL input that forgets to append the path.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- failed to evaluate expression
- Unexpected third argument to Deno.bench()
- Invalid type for fetch: must be a function
- Invalid type for onListen: must be a function
- ERR_MISSING_ARGS
AI-assisted analysis of denoland/deno@9ad36f7a2c (2026-08-20).
Data as JSON: /api/errors/c47a6dc62ffdbb24.
Report an issue: GitHub.