denoland/deno · error
Unknown package kind: {}
Error message
Unknown package kind: {} What it means
`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.
Source
Thrown at cli/tools/init/mod.rs:46
use crate::colors;
use crate::util::env::resolve_cwd;
use crate::util::temp::create_temp_node_modules_dir;
pub async fn init_project(
flags: Flags,
init_flags: InitFlags,
) -> Result<i32, AnyError> {
if let Some(package) = &init_flags.package {
if package.starts_with("jsr:") {
return init_jsr(package, init_flags.package_args, init_flags.yes)
.boxed_local()
.await;
} else if package.starts_with("npm:") {
return init_npm(package, init_flags.package_args, init_flags.yes)
.boxed_local()
.await;
} else {
bail!("Unknown package kind: {}", package);
}
}
let cwd = resolve_cwd(flags.initial_cwd.as_deref())?;
let dir = if let Some(dir) = &init_flags.dir {
let dir = cwd.join(dir);
std::fs::create_dir_all(&dir)?;
Cow::Owned(dir)
} else {
cwd
};
if init_flags.empty {
create_file(
&dir,
"main.ts",
r#"console.log('Hello world!');
"#,View on GitHub (pinned to 9ad36f7a2c)
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
Example fix
# before deno init vite # after deno init npm:vite # or deno init --npm vite # plain local project instead: deno init my_project
Defensive patterns
Strategy: validation
Validate before calling
# validate the package spec before calling init in scripts: case "$pkg" in jsr:*|npm:*) deno init "$pkg" ;; *) echo "prefix with jsr: or npm:" >&2; exit 1 ;; esac
Type guard
// JS wrapper
class PkgSpec {
static isTemplateSpec(s) {
return s.startsWith("jsr:") || s.startsWith("npm:");
}
} Try / catch
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>`.
Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Invalid type for fetch: must be a function
- Invalid type for onListen: must be a function
- ERR_PARSE_ARGS_INVALID_OPTION_VALUE
- ERR_PARSE_ARGS_UNKNOWN_OPTION
- ERR_INVALID_ARG_VALUE
AI-assisted analysis of denoland/deno@9ad36f7a2c (2026-08-20).
Data as JSON: /api/errors/2fe2e5daec0e2fce.
Report an issue: GitHub.