{"record":{"id":"77bb4404e11f522f","repo":"nodejs/node","slug":"no-workspaces-found-msg","errorCode":null,"errorMessage":"No workspaces found${msg}","messagePattern":"No workspaces found(.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"deps/npm/lib/utils/get-workspaces.js","lineNumber":48,"sourceCode":"      const relativeFilter = relative(path, filterArg)\n      if (filterArg === workspaceName\n        || resolve(relativeFrom, filterArg) === workspacePath\n        || minimatch(relativePath, `${globify(relativeFilter)}/*`)\n        || minimatch(relativePath, `${globify(filterArg)}/*`)\n      ) {\n        res.set(workspaceName, workspacePath)\n      }\n    }\n  }\n\n  if (!res.size) {\n    let msg = '!'\n    if (filters.length) {\n      msg = `:\\n ${filters.reduce(\n        (acc, filterArg) => `${acc} --workspace=${filterArg}`, '')}`\n    }\n\n    throw new Error(`No workspaces found${msg}`)\n  }\n\n  return res\n}\n\nmodule.exports = getWorkspaces\n","sourceCodeStart":30,"sourceCodeEnd":55,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/npm/lib/utils/get-workspaces.js#L30-L55","documentation":"Thrown by getWorkspaces when, after applying any --workspace filters against the discovered workspace map (plus optional root), the result map is empty. With no filters the message is 'No workspaces found!' (no colon list); with filters it lists each as ' --workspace=<filter>'. The workspaces come from @npmcli/map-workspaces reading the root package.json `workspaces` field.","triggerScenarios":"Any workspace-aware command (`-w`, `-ws`) when: (a) the root package.json has no `workspaces` field at all and no filter matches; (b) a filter name/path does not match any configured workspace; (c) the workspaces glob exists but the matched directories lack their own package.json.","commonSituations":"Typo in `--workspace` name; running in a non-monorepo; workspace globs out of sync with directory layout; renamed a workspace package but not the filter.","solutions":["Verify the root package.json has a `workspaces` array/glob and that matching directories contain package.json files.","List valid workspace names from your root package.json and correct the `--workspace` filter spelling/path.","Drop the workspace flag if you did not mean to operate in workspace mode."],"exampleFix":"// before\n// package.json has \"workspaces\": [\"packages/*\"] but no packages/a dir\nnpm install --workspace=packge-a   // typo\n// after\nnpm install --workspace=package-a","handlingStrategy":"validation","validationCode":"const root = JSON.parse(await readFile('package.json', 'utf8'))\nconst wsMap = await mapWorkspaces({ cwd: process.cwd(), pkg: root })\nfor (const f of filters) {\n  if (!wsMap.has(f)) {\n    throw new Error(`--workspace=${f} matches no configured workspace; valid: ${[...wsMap.keys()].join(', ')}`)\n  }\n}","typeGuard":"const isValidWorkspaceFilter = (filters, wsMap) =>\n  filters.every(f => wsMap.has(f))","tryCatchPattern":"try {\n  await getWorkspaces(filters, opts)\n} catch (err) {\n  if (/No workspaces found/i.test(err.message)) {\n    // log the available workspace names from package.json, then re-prompt\n  } else { throw err }\n}","preventionTips":["Keep package.json `workspaces` globs in sync with your directory layout.","List valid workspace names before scripting `-w` filters.","Validate filter names against the workspace map in your wrapper."],"tags":["validation","workspaces","monorepo","cli-args"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}