{"record":{"id":"b5ec2a9423faf664","repo":"withastro/astro","slug":"unable-to-resolve-packagename-is-it-a-depend","errorCode":null,"errorMessage":"Unable to resolve \"${packageName}\". Is it a dependency of the workspace root?","messagePattern":"Unable to resolve \"(.+?)\"\\. Is it a dependency of the workspace root\\?","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/cmd/build.js","lineNumber":179,"sourceCode":"\treturn Object.entries(define);\n}\n\nasync function readPackageJSON(path) {\n\treturn await fs.readFile(path, { encoding: 'utf8' }).then((res) => JSON.parse(res));\n}\n\nasync function getInternalPackageVersion(path) {\n\treturn readPackageJSON(path).then((res) => res.version);\n}\n\nasync function getWorkspacePackageVersion(packageName) {\n\tconst { dependencies, devDependencies } = await readPackageJSON(\n\t\tnew URL('../../package.json', import.meta.url),\n\t);\n\tconst deps = { ...dependencies, ...devDependencies };\n\tconst version = deps[packageName];\n\tif (!version) {\n\t\tthrow new Error(\n\t\t\t`Unable to resolve \"${packageName}\". Is it a dependency of the workspace root?`,\n\t\t);\n\t}\n\treturn version.replace(/^\\D+/, '');\n}\n","sourceCodeStart":161,"sourceCodeEnd":185,"githubUrl":"https://github.com/withastro/astro/blob/d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca/scripts/cmd/build.js#L161-L185","documentation":"Thrown by `getWorkspacePackageVersion` in the monorepo build script when a requested internal package name is not listed in the root `package.json`'s `dependencies` or `devDependencies`. The script reads the workspace root manifest, merges both dep maps, and looks up the name; a miss means the build cannot determine which version of the internal package to use.","triggerScenarios":"Calling the build script with a `--package <name>` (or internal lookup) for a package that is not hoisted to the workspace root — e.g. a new integration that was added to `packages/integrations/` but never added to the root manifest; a renamed package; a package that is only a transitive dependency.","commonSituations":"A contributor adds a new workspace package but forgets to add it to root `package.json`; renaming a package without updating the root deps; running a build step targeting a package that exists in `packages/` but is consumed only via workspaces, not listed at root.","solutions":["Add the missing package to the root `package.json` under `dependencies` or `devDependencies` (commonly as `workspace:*` or a version range), then `pnpm install`.","Verify the spelling/scope of the package name matches the `name` field in its own `package.json`.","If the package should not be a root dependency, change the caller to resolve its version from its own `package.json` (e.g. via `getInternalPackageVersion`) instead of the workspace root."],"exampleFix":"// before — root package.json missing the entry\n\"dependencies\": { \"astro\": \"workspace:*\" }\n\n// after — add the internal package\n\"dependencies\": { \"astro\": \"workspace:*\", \"@astrojs/jsx\": \"workspace:*\" }","handlingStrategy":"validation","validationCode":"import { readPackageJSON } from './util.js';\nasync function isInWorkspaceRoot(packageName: string): Promise<boolean> {\n  const { dependencies = {}, devDependencies = {} } =\n    await readPackageJSON(new URL('../../package.json', import.meta.url));\n  return packageName in dependencies || packageName in devDependencies;\n}\n// guard before calling getWorkspacePackageVersion","typeGuard":"function isRootDep(rootManifest: { dependencies?: Record<string,string>; devDependencies?: Record<string,string> }, name: string): boolean {\n  return Boolean(rootManifest.dependencies?.[name] ?? rootManifest.devDependencies?.[name]);\n}","tryCatchPattern":null,"preventionTips":["When adding a new workspace package, add it to the root package.json dependencies in the same commit.","Run `pnpm install` after editing the root manifest so the workspace link is created.","In CI, assert that every package under packages/ is referenced from the root manifest."],"tags":["build-script","monorepo","workspace","dependency-resolution"],"backgroundTag":null,"analyzedSha":"d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca","analyzedAt":"2026-08-12T13:37:29.035Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}