denoland/deno · error · anyhow::Error
Invalid YAML: {e}
Error message
Invalid YAML: {e} What it means
Thrown while parsing pnpm-workspace.yaml for a Deno workspace that uses pnpm. Deno reuses the yaml_parser CST that powers `deno fmt` (no new YAML dependency); when that parser reports a syntax error, this message wraps it and appends the parser's position details after the colon.
Source
Thrown at cli/util/pnpm_workspace.rs:252
}
fn string_map_to_value(map: &IndexMap<String, String>) -> CstInputValue {
CstInputValue::Object(
map
.iter()
.map(|(k, v)| (k.clone(), CstInputValue::String(v.clone())))
.collect(),
)
}
// ===========================================================================
// pnpm-workspace.yaml parsing (via the yaml_parser CST already used by
// `deno fmt`, so no new YAML dependency is introduced).
// ===========================================================================
fn parse_pnpm_workspace(text: &str) -> Result<PnpmWorkspace, AnyError> {
let tree = yaml_parser::parse(text)
.map_err(|e| deno_core::anyhow::anyhow!("Invalid YAML: {e}"))?;
let Some(root) = Root::cast(tree) else {
return Ok(PnpmWorkspace::default());
};
let Some(block_map) = root
.documents()
.next()
.and_then(|doc: Document| doc.block())
.and_then(|block| block.block_map())
else {
return Ok(PnpmWorkspace::default());
};
let mut result = PnpmWorkspace::default();
for entry in block_map.entries() {
let Some(key) = entry.key().map(|k| k.syntax().clone()) else {
continue;
};
let Some(key_name) = scalar_text(&key) else {View on GitHub (pinned to 89f33cbef2)
Solutions
- Fix the YAML syntax at the position reported after 'Invalid YAML:' (replace tabs with spaces, balance quotes and brackets)
- Validate the file outside Deno, e.g. `pnpm install --lockfile-only` or a YAML linter, to confirm it parses
- If the project does not actually use pnpm workspaces, delete or rename pnpm-workspace.yaml so Deno stops parsing it
Example fix
# pnpm-workspace.yaml (before) — tab-indented, invalid YAML packages: - "apps/*" # after — space-indented packages: - "apps/*"
Defensive patterns
Strategy: validation
Validate before calling
// CI pre-check: parse pnpm-workspace.yaml before any deno command
import { parse } from "jsr:@std/yaml";
try {
parse(await Deno.readText("pnpm-workspace.yaml"));
console.log("pnpm-workspace.yaml OK");
} catch (e) {
console.error(`Invalid YAML: ${e}`);
Deno.exit(1);
} Prevention
- Indent pnpm-workspace.yaml with spaces only — tabs are invalid YAML indentation
- Run a YAML linter or editor YAML plugin on the file in CI
- A file that `pnpm install` accepts will also parse in Deno — validate with pnpm when in doubt
When it happens
Trigger: Any `deno` CLI command that loads workspace config (`deno install`, `deno run`, `deno task`, ...) when pnpm-workspace.yaml contains invalid YAML: tab indentation, unbalanced quotes or flow brackets ([/]), duplicate keys rejected by the parser, or a stray control character.
Common situations: Hand-editing the `packages:` list and mixing tabs with spaces; pasting YAML from docs or chat that includes smart quotes; a merge leaving an unbalanced bracket; editors inserting a BOM.
Related errors
- No bench modules found
- Task not found: {}
- The bench name can't be empty
- Unexpected 'name' field in options, bench name is already pr
- Unexpected second argument to Deno.bench()
AI-assisted analysis of denoland/deno@89f33cbef2 (2026-08-16).
Data as JSON: /api/errors/fd201cb16e3e77e8.
Report an issue: GitHub.