{"record":{"id":"e10b5419a7547a66","repo":"denoland/deno","slug":"unable-to-find-npm-package-in-workspace","errorCode":null,"errorMessage":"unable to find npm package in workspace","messagePattern":"unable to find npm package in workspace","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"cli/tools/publish/unfurl.rs","lineNumber":675,"sourceCode":"        referrer,\n        relative_resolved\n      );\n      Ok(Some(relative_resolved))\n    }\n  }\n\n  fn find_workspace_npm_dep_version(\n    &self,\n    pkg_name: &str,\n  ) -> Result<Version, anyhow::Error> {\n    // todo(#24612): warn when this is also a jsr package telling\n    // people to map the specifiers in the import map\n    let pkg_json = self\n      .workspace_resolver\n      .package_jsons()\n      .find(|pkg| pkg.name.as_deref() == Some(pkg_name))\n      .ok_or_else(|| {\n        anyhow::anyhow!(\"unable to find npm package in workspace\")\n      })?;\n    if let Some(version) = &pkg_json.version {\n      Ok(Version::parse_from_npm(version)?)\n    } else {\n      Err(anyhow::anyhow!(\n        \"missing version in package.json of npm package\",\n      ))\n    }\n  }\n\n  /// Look up the version constraint for a @types/* package from package.json\n  /// dependencies (including devDependencies) or from the import map.\n  fn find_types_package_version_req(\n    &self,\n    types_package_name: &str,\n    referrer: &ModuleSpecifier,\n  ) -> Option<VersionReq> {\n    // check package.json dependencies","sourceCodeStart":657,"sourceCodeEnd":693,"githubUrl":"https://github.com/denoland/deno/blob/89f33cbef296a2b287f323d42de54c871fa69c77/cli/tools/publish/unfurl.rs#L657-L693","documentation":"When publishing to JSR, Deno rewrites ('unfurls') npm specifiers found in published source into pinned versions. For a package expected to be an npm workspace member, `find_workspace_npm_dep_version` searches every workspace package.json for one whose `name` matches; finding none produces this error. A source todo (#24612) notes a missing warning for packages that are also published to JSR.","triggerScenarios":"Published source (or its import-map resolution) references an npm package as a workspace dependency, but no workspace member's package.json has `\"name\"` equal to that package name — the member was removed, renamed, or never existed in the workspace.","commonSituations":"Monorepos mixing JSR and npm packages; renaming a package in package.json without updating importers; deleting a member while imports remain; import maps pointing at packages that are not workspace members.","solutions":["Add the npm package as a workspace member whose package.json `\"name\"` exactly matches the imported package name","If the package was renamed, update the imports to the new name","Change the specifier to a plain `npm:package@version` dependency instead of a workspace reference"],"exampleFix":"// before — importer uses npm:shared-lib but member name diverges\n// packages/shared/package.json\n{ \"name\": \"@acme/shared-lib\", \"version\": \"0.1.0\" }\n// after — names match\n{ \"name\": \"shared-lib\", \"version\": \"0.1.0\" }","handlingStrategy":"validation","validationCode":"# before publish: every npm: specifier treated as a workspace dep must\n# match some member package.json \"name\"\ngrep -rhoE 'npm:[@a-z0-9-]+(/[a-z0-9._-]+)?@?[^\"'\"'']*' src --include='*.ts' | sort -u \\\n  | while read -r spec; do\n      name=$(echo \"$spec\" | sed -E 's|^npm:||; s|@[^/]*$||; s|(@[^/]+)$|\\1|')\n      found=$(find . -name package.json -not -path '*/node_modules/*' \\\n        -exec grep -l \"\\\"name\\\": \\\"$name\\\"\" {} +)\n      [ -n \"$found\" ] || echo \"no workspace member named: $name\"\n    done","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep member package.json `name` fields in lockstep with the specifiers importers use","When removing or renaming an npm workspace member, grep for its specifier before publishing","Run `deno publish --dry-run` — unfurling errors surface there without uploading"],"tags":["publish","jsr","npm","workspace","unfurl"],"backgroundTag":null,"analyzedSha":"89f33cbef296a2b287f323d42de54c871fa69c77","analyzedAt":"2026-08-16T07:54:21.310Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}