{"record":{"id":"974fab3dd7c9c04b","repo":"denoland/deno","slug":"hint","errorCode":null,"errorMessage":"{hint}","messagePattern":"\\{hint\\}","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/tools/pm/mod.rs","lineNumber":615,"sourceCode":"  let deps_file_fetcher = Arc::new(deps_file_fetcher);\n  let jsr_resolver = Arc::new(JsrFetchResolver::new(\n    deps_file_fetcher.clone(),\n    cli_factory.jsr_version_resolver()?.clone(),\n  ));\n  let npm_resolver = Arc::new(NpmFetchResolver::new(\n    deps_file_fetcher,\n    npmrc.clone(),\n    cli_factory.npm_version_resolver()?.clone(),\n  ));\n\n  let mut selected_packages = Vec::with_capacity(add_flags.packages.len());\n  let mut package_reqs: Vec<AddRmPackageReq> =\n    Vec::with_capacity(add_flags.packages.len());\n\n  let initial_cwd = cli_factory.cli_options()?.initial_cwd().to_path_buf();\n  for entry_text in add_flags.packages.iter() {\n    if let Some(hint) = link_hint_for_spec(&initial_cwd, entry_text) {\n      bail!(\"{hint}\");\n    }\n    let req = AddRmPackageReq::parse(\n      entry_text,\n      add_flags.default_registry.map(|r| r.into()),\n    )\n    .with_context(|| format!(\"Failed to parse package: {}\", entry_text))?;\n\n    match req {\n      Ok(mut add_req) => {\n        if add_flags.unscoped {\n          add_req.use_unscoped_alias();\n          // packages from different scopes can share an unscoped name\n          // (ex. `@luca/flag` and `@other/flag`), which would otherwise\n          // silently overwrite each other in the config\n          if let Some(existing) =\n            package_reqs.iter().find(|r| r.alias == add_req.alias)\n          {\n            bail!(","sourceCodeStart":597,"sourceCodeEnd":633,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/cli/tools/pm/mod.rs#L597-L633","documentation":"During `deno add`, `link_hint_for_spec` detects arguments that are path-shaped (., .., ./x, containing separators) and point at an existing local directory whose deno.json(c) declares a `name` — i.e. a linkable local JSR package. Adding local directories as registry deps is not supported, so Deno stops you and suggests `deno link` in the message.","triggerScenarios":"`deno add ./packages/my-lib` (or ../other, /abs/path) where that directory exists and its deno.json has a `name` field. Bare names like `deno add chalk` never trigger it; non-existent paths are passed through to normal parsing.","commonSituations":"Monorepos where sibling packages are consumed locally; users expecting npm-style `file:` installs; refactoring a workspace member into consumption via add.","solutions":["Use `deno link ./packages/my-lib` as the message suggests (wires the local package into the workspace).","If the path was accidental, fix the specifier to a real registry package (e.g. `npm:chalk`).","For local-only development without linking, add a workspace member entry or a relative import instead of `deno add`."],"exampleFix":"# before\ndeno add ./packages/my-lib\n# after\ndeno link ./packages/my-lib","handlingStrategy":"validation","validationCode":"import { statSync, readFileSync, isAbsolute, resolve } from \"node:fs\";\nimport { join } from \"node:path\";\nconst spec = process.argv[2] ?? \"\";\nconst looksPathy = spec === \".\" || spec === \"..\" || spec.includes(\"/\") || spec.includes(\"\\\\\") || isAbsolute(spec);\nif (looksPathy) {\n  const abs = resolve(spec);\n  try {\n    if (statSync(abs).isDirectory()) {\n      const target = JSON.parse(readFileSync(join(abs, \"deno.json\"), \"utf8\"));\n      if (target.name) {\n        console.error(`${spec} is a local package; use: deno link ${spec}`);\n        process.exit(1);\n      }\n    }\n  } catch { /* not a linkable package dir */ }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use `deno link <path>` for local JSR packages; `deno add` is for registry packages.","Detect path-shaped arguments in wrappers and route them to link.","Workspace members with names are link targets; bare folders are not."],"tags":["add","local-package","workspace","link"],"backgroundTag":"local-package-path-in-add","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}