denoland/deno · error · AnyError
No target files found.
Error message
No target files found.
What it means
`deno fmt` collects the files it will format from the workspace members (respecting each member's fmt.files include/exclude config). If every member's collection comes back empty and --permit-no-files was not passed, fmt refuses to run at all — this error. It exists so scripts and CI fail loudly when their include patterns silently match nothing, instead of formatting zero files and reporting success.
Solutions
- If zero files is expected (skeleton repo, CI job that may have nothing to format), add --permit-no-files so an empty set is OK.
- Otherwise check what fmt would see: run `deno fmt --check` with the same args, or list matches via `deno fmt` without an enclosing deno.json excludes; fix the include/exclude config in deno.json ("fmt": { "files": { ... } }).
- Verify you are running from the workspace root and the files actually exist (a failed checkout or wrong working dir matches nothing).
- Check explicit path arguments for typos — a wrong path filters to empty just like an exclude.
Example fix
# before
deno fmt
# error: No target files found.
# after — if empty is legitimate:
deno fmt --permit-no-files
# after — if files should have matched, fix the config:
# deno.json: { "fmt": { "exclude": ["vendor"] } } -> narrow the exclude so src/ matches Defensive patterns
Strategy: validation
Validate before calling
# In CI, either assert there is something to format, or permit empty explicitly if find . -name '*.ts' -o -name '*.js' | grep -q .; then deno fmt --check else deno fmt --check --permit-no-files # empty workspace is fine fi
Try / catch
In scripts, run fmt with --permit-no-files only when an empty file set is acceptable; otherwise catch the 'No target files found.' exit and fail loudly — it usually means the checkout or include config broke, which you want to know about.
Prevention
- Add --permit-no-files to CI fmt/lint/bench/test steps where repositories may legitimately have no matching files.
- After renaming directories, re-check the fmt.files include/exclude config in deno.json — stale paths silently match nothing.
- Treat a sudden 'No target files found.' in CI as a red flag for a failed checkout step, not as a formatting problem.
When it happens
Trigger: Running `deno fmt` in a directory with no formattable files (no .ts/.js/.json/... after excludes), or with deno.json fmt exclude patterns / explicit path arguments that filter everything out, without --permit-no-files. The same guard exists in deno lint/bench/test behind their own permit_no_files flags.
Common situations: A generated project where all sources live in an excluded directory (vendor/, gen/); CI where the checkout step failed silently so there are no files; passing an extension argument that matches nothing (deno fmt --ext ts in a pure-.md repo); fmt.files includes a directory name that was renamed.
Related errors
- Did not format non-workspace directory. Run again…
- An executable name was not provided. One could not be…
- app name resolves its to , which is already part of the…
- Bad cluster.schedulingPolicy
- Bench failed because the "only" option was used
AI-assisted analysis of denoland/deno@9ad36f7a2c (2026-08-20).
Data as JSON: /api/errors/a68d3df8636d6dfe.
Report an issue: GitHub.
Appendix: source
Thrown at cli/tools/fmt.rs:205
maybe_show_format_confirmation(cli_options, fmt_flags)?;
let members_fmt_options =
cli_options.resolve_fmt_options_for_members(fmt_flags)?;
let mut paths_with_options_batches =
Vec::with_capacity(members_fmt_options.len());
for (_ctx, member_fmt_options) in members_fmt_options {
let files =
collect_fmt_files(cli_options, member_fmt_options.files.clone());
if !files.is_empty() {
paths_with_options_batches.push(PathsWithOptions {
base: member_fmt_options.files.base.clone(),
paths: files,
options: member_fmt_options,
});
}
}
if paths_with_options_batches.is_empty() && !fmt_flags.permit_no_files {
return Err(anyhow!("No target files found."));
}
Ok(paths_with_options_batches)
}
fn maybe_show_format_confirmation(
cli_options: &CliOptions,
fmt_flags: &FmtFlags,
) -> Result<(), AnyError> {
if fmt_flags.check
|| !fmt_flags.files.include.is_empty()
|| cli_options.workspace().deno_jsons().next().is_some()
|| cli_options.workspace().package_jsons().next().is_some()
{
return Ok(());
}
let confirm_result =
util::console::confirm(util::console::ConfirmOptions {View on GitHub (pinned to 9ad36f7a2c)