yarnpkg/yarn · error · MessageError
workspaceRootNotFound
Error message
workspaceRootNotFound
What it means
Thrown by 'yarn workspaces info' when config.workspaceRootFolder is falsy. As with error 55, Yarn could not find an ancestor manifest declaring a 'workspaces' field, so there is no workspace tree to report on.
Source
Thrown at src/cli/commands/workspaces.js:24
import buildSubCommands from './_build-sub-commands.js';
import {DEPENDENCY_TYPES} from '../../constants.js';
import * as child from '../../util/child.js';
import {NODE_BIN_PATH, YARN_BIN_PATH} from '../../constants';
const invariant = require('invariant');
const path = require('path');
const os = require('os');
const semver = require('semver');
export function hasWrapper(commander: Object, args: Array<string>): boolean {
return true;
}
export async function info(config: Config, reporter: Reporter, flags: Object, args: Array<string>): Promise<void> {
const {workspaceRootFolder} = config;
if (!workspaceRootFolder) {
throw new MessageError(reporter.lang('workspaceRootNotFound', config.cwd));
}
const manifest = await config.findManifest(workspaceRootFolder, false);
invariant(manifest && manifest.workspaces, 'We must find a manifest with a "workspaces" property');
const workspaces = await config.resolveWorkspaces(workspaceRootFolder, manifest);
const publicData = {};
for (const workspaceName of Object.keys(workspaces)) {
const {loc, manifest} = workspaces[workspaceName];
const workspaceDependencies = new Set();
const mismatchedWorkspaceDependencies = new Set();
for (const dependencyType of DEPENDENCY_TYPES) {
if (dependencyType !== 'peerDependencies') {
for (const dependencyName of Object.keys(manifest[dependencyType] || {})) {View on GitHub (pinned to c2dda503f3)
Solutions
- Run from within a workspace project root.
- Add a 'workspaces' field to the root package.json and run 'yarn install'.
- If you only have one package, 'yarn workspaces info' is not applicable.
Example fix
// before (root package.json)
{ "name": "root", "private": true }
// after
{
"name": "root",
"private": true,
"workspaces": ["packages/*"]
} Defensive patterns
Strategy: validation
Validate before calling
if (!config.workspaceRootFolder) {
throw new Error(`No workspace root found from ${config.cwd}; declare 'workspaces' in the root manifest and run 'yarn install'.`);
} Type guard
function hasWorkspaceRoot(config: Config): boolean {
return typeof config.workspaceRootFolder === 'string' && config.workspaceRootFolder.length > 0;
} Prevention
- Define 'workspaces' in the root manifest before running 'yarn workspaces info'.
- Run the command from the workspace root.
- Add a CI lint that the root manifest has 'workspaces' for monorepos.
When it happens
Trigger: Running 'yarn workspaces info' in a directory whose ancestor chain has no package.json with a 'workspaces' field (or outside any project).
Common situations: Single-package project (no workspaces); root manifest missing the 'workspaces' key; wrong cwd.
Related errors
- workspaceRootNotFound
- The workspaces field in package.json must be an array.
- unknownPackageName
- unknownPackageName
- workspaceUnknownWorkspace
AI-assisted analysis of yarnpkg/yarn@c2dda503f3 (2026-08-13).
Data as JSON: /api/errors/7f98892e05e7c537.
Report an issue: GitHub.