{"record":{"id":"c828155e66f0d7ab","repo":"yarnpkg/yarn","slug":"founderrors","errorCode":null,"errorMessage":"foundErrors","messagePattern":"foundErrors","errorType":"exception","errorClass":"MessageError","httpStatus":null,"severity":"error","filePath":"src/cli/commands/check.js","lineNumber":152,"sourceCode":"              version: dependencies[subdep],\n            });\n            found = true;\n            break;\n          }\n          if (!locations.length) {\n            break;\n          }\n          locations.pop();\n        }\n        if (!found) {\n          reportError('packageNotInstalled', `${dep.originalKey}#${subdep}`);\n        }\n      }\n    }\n  }\n\n  if (errCount > 0) {\n    throw new MessageError(reporter.lang('foundErrors', errCount));\n  } else {\n    reporter.success(reporter.lang('folderInSync'));\n  }\n}\n\nasync function integrityHashCheck(\n  config: Config,\n  reporter: Reporter,\n  flags: Object,\n  args: Array<string>,\n): Promise<void> {\n  let errCount = 0;\n  function reportError(msg, ...vars) {\n    reporter.error(reporter.lang(msg, ...vars));\n    errCount++;\n  }\n  const integrityChecker = new InstallationIntegrityChecker(config);\n","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/yarnpkg/yarn/blob/c2dda503f3759b5be5f0e24ecd9cf5c97a540147/src/cli/commands/check.js#L134-L170","documentation":"`yarn check --verify-tree` walks `node_modules` and reports one error per defect via `reportError` (which increments `errCount`). At `check.js:152`, if `errCount > 0`, it throws `foundErrors` with the count. The errors aggregated here are `packageNotInstalled` and `packageWrongVersion` — installed tree does not match the lockfile/manifest.","triggerScenarios":"Any `reportError('packageNotInstalled'|'packageWrongVersion', ...)` call during the verify-tree loop, i.e. a package listed in dependencies is missing from node_modules or its installed version does not satisfy the declared range.","commonSituations":"Partially populated `node_modules` after an interrupted install, manual deletion of a package, drift between `package.json`/`yarn.lock` and the on-disk tree, or platform-specific optional deps not cleaned up.","solutions":["Run `yarn install --force` to reconcile the tree.","If still failing: `rm -rf node_modules && yarn install`.","Inspect the individual `packageNotInstalled`/`packageWrongVersion` lines above the throw for the specific offender."],"exampleFix":"// before\n$ yarn check --verify-tree\n→ Found 3 errors.\n\n// after\n$ rm -rf node_modules yarn.lock\n$ yarn install","handlingStrategy":"try-catch","validationCode":"// Pre-check that every declared dependency is physically present\nimport fs from 'fs';\nimport path from 'path';\n\nasync function depsPresent(rootDeps: Record<string,string>, cwd: string): Promise<string[]> {\n  const missing: string[] = [];\n  for (const name of Object.keys(rootDeps)) {\n    if (!fs.existsSync(path.join(cwd, 'node_modules', name, 'package.json'))) missing.push(name);\n  }\n  return missing;\n}\n// if ((await depsPresent(pkg.dependencies, cwd)).length) await rebuild();","typeGuard":null,"tryCatchPattern":"try {\n  await check(config, reporter, { verifyTree: true }, []);\n} catch (e) {\n  if (/Found \\d+ errors/.test(e.message)) {\n    await rebuildNodeModules(); // rm -rf node_modules && yarn install\n  } else throw e;\n}","preventionTips":["Never hand-edit node_modules; always go through yarn install.","After an interrupted install, treat the tree as untrusted and reinstall."],"tags":["yarn-check","verify-tree","node-modules","integrity"],"backgroundTag":null,"analyzedSha":"c2dda503f3759b5be5f0e24ecd9cf5c97a540147","analyzedAt":"2026-08-13T04:17:06.305Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}