{"record":{"id":"2fe2e5daec0e2fce","repo":"denoland/deno","slug":"unknown-package-kind","errorCode":null,"errorMessage":"Unknown package kind: {}","messagePattern":"Unknown package kind: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/tools/init/mod.rs","lineNumber":46,"sourceCode":"use crate::colors;\nuse crate::util::env::resolve_cwd;\nuse crate::util::temp::create_temp_node_modules_dir;\n\npub async fn init_project(\n  flags: Flags,\n  init_flags: InitFlags,\n) -> Result<i32, AnyError> {\n  if let Some(package) = &init_flags.package {\n    if package.starts_with(\"jsr:\") {\n      return init_jsr(package, init_flags.package_args, init_flags.yes)\n        .boxed_local()\n        .await;\n    } else if package.starts_with(\"npm:\") {\n      return init_npm(package, init_flags.package_args, init_flags.yes)\n        .boxed_local()\n        .await;\n    } else {\n      bail!(\"Unknown package kind: {}\", package);\n    }\n  }\n\n  let cwd = resolve_cwd(flags.initial_cwd.as_deref())?;\n  let dir = if let Some(dir) = &init_flags.dir {\n    let dir = cwd.join(dir);\n    std::fs::create_dir_all(&dir)?;\n    Cow::Owned(dir)\n  } else {\n    cwd\n  };\n\n  if init_flags.empty {\n    create_file(\n      &dir,\n      \"main.ts\",\n      r#\"console.log('Hello world!');\n\"#,","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/cli/tools/init/mod.rs#L28-L64","documentation":"`deno init` only scaffolds from a template package when the package value starts with `jsr:` or `npm:` (routed to init_jsr/init_npm). This bail is a defensive guard for a package value that carries neither prefix. The argument parser normally rejects unprefixed names earlier with a 'Missing jsr: or npm: prefix' message, so seeing this specific text usually means an internal routing edge rather than ordinary CLI usage.","triggerScenarios":"init_flags.package is Some(...) but the string lacks both prefixes — possible via internal API misuse, a future flag path that sets package directly, or a custom build of the CLI; user-level equivalents like `deno init --npm ''`-style oddities are caught at parse time instead.","commonSituations":"Users typing `deno init vite` expecting a template and getting the parser's prefix error (the sibling of this guard); forks/embedders constructing InitFlags by hand.","solutions":["Use an explicit prefix: `deno init npm:vite` or `deno init jsr:@fresh/init`","Or use the flags: `deno init --npm vite` / `deno init --jsr @fresh/init`","For a plain local starter project, use `deno init [dir]` with no package argument"],"exampleFix":"# before\ndeno init vite\n\n# after\ndeno init npm:vite\n# or\ndeno init --npm vite\n# plain local project instead:\ndeno init my_project","handlingStrategy":"validation","validationCode":"# validate the package spec before calling init in scripts:\ncase \"$pkg\" in jsr:*|npm:*) deno init \"$pkg\" ;; *) echo \"prefix with jsr: or npm:\" >&2; exit 1 ;; esac","typeGuard":"// JS wrapper\nclass PkgSpec {\n  static isTemplateSpec(s) {\n    return s.startsWith(\"jsr:\") || s.startsWith(\"npm:\");\n  }\n}","tryCatchPattern":"Catch init failures; if the message mentions package kind/prefix, re-run with the corrected `npm:`/`jsr:`-prefixed specifier or fall back to plain `deno init <dir>`.","preventionTips":["Always template with `deno init npm:<name>` or `deno init --npm <name>`","Use bare `deno init [dir]` for local starter projects","Automate old `deno create` snippets to add the prefix when migrating docs"],"tags":["init","package-specifier","cli","scaffold"],"backgroundTag":"invalid-package-specifier","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}