{"record":{"id":"76a9e519b821e1ea","repo":"nodejs/node","slug":"cannot-use-no-workspaces-and-workspace-at-the","errorCode":null,"errorMessage":"Cannot use --no-workspaces and --workspace at the same time","messagePattern":"Cannot use --no-workspaces and --workspace at the same time","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"deps/npm/lib/base-cmd.js","lineNumber":150,"sourceCode":"    const helpName = parentName ? parentName.split(' ')[0] : name\n    fullUsage.push(`Run \"npm help ${helpName}\" for more info`)\n\n    return fullUsage.join('\\n')\n  }\n\n  constructor (npm) {\n    this.npm = npm\n    this.commandArgs = null\n    this.parentName = null\n\n    const { config } = this\n\n    if (!this.constructor.skipConfigValidation) {\n      config.validate()\n    }\n\n    if (config.get('workspaces') === false && config.get('workspace').length) {\n      throw new Error('Cannot use --no-workspaces and --workspace at the same time')\n    }\n  }\n\n  get config () {\n    // Return command-specific config if it exists, otherwise use npm's config\n    return this.npm.config\n  }\n\n  get name () {\n    return this.constructor.name\n  }\n\n  get description () {\n    return this.constructor.description\n  }\n\n  get params () {\n    return this.constructor.params","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/npm/lib/base-cmd.js#L132-L168","documentation":"In the base command constructor, npm validates that you have not combined --no-workspaces (disable workspace expansion) with one or more --workspace/-w selectors. These are contradictory intents, so the command refuses to run rather than guess which wins.","triggerScenarios":"Passing both flags on one invocation, e.g. `npm run build --workspace=pkg-a --no-workspaces`. Also triggered when an .npmrc or package.json 'workspace' config is set and the CLI adds --no-workspaces (or vice-versa).","commonSituations":"CI matrix scripts that append -w flags to a base command which itself ships --no-workspaces; shell aliases; inheriting workspace config from a monorepo root while debugging a single package with --no-workspaces.","solutions":["Drop --no-workspaces when you actually want to target the listed workspace(s)","Drop all --workspace/-w flags if your intent is to disable workspace expansion entirely","Audit .npmrc and the nearest package.json 'workspaces' field plus npm_config_workspace env for stale values"],"exampleFix":"# before\nnpm run test --workspace=pkg-a --no-workspaces\n\n# after\nnpm run test --workspace=pkg-a","handlingStrategy":"validation","validationCode":"const cfg = npm.config\nconst conflict = cfg.get('workspaces') === false && cfg.get('workspace').length > 0\nif (conflict) {\n  throw new Error('Refusing to run: --no-workspaces conflicts with --workspace selectors')\n}","typeGuard":"function workspaceFlagsConflict(cfg) {\n  return cfg.get('workspaces') === false && Array.isArray(cfg.get('workspace')) && cfg.get('workspace').length > 0\n}","tryCatchPattern":null,"preventionTips":["Standardize workspace invocation in shared scripts so flags come from one source","CI: do not blanket-append --no-workspaces to monorepo commands","Document the intended scope (single workspace vs all) per script"],"tags":["workspaces","config-validation","cli","monorepo"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}