{"record":{"id":"cfdb1d407109de39","repo":"yarnpkg/yarn","slug":"outdated-lockfile-please-run-yarn-install-and-t","errorCode":null,"errorMessage":"Outdated lockfile. Please run `yarn install` and try again.","messagePattern":"Outdated lockfile\\. Please run `yarn install` and try again\\.","errorType":"exception","errorClass":"MessageError","httpStatus":null,"severity":"error","filePath":"src/package-request.js","lineNumber":409,"sourceCode":"    // filter the list down to just the packages requested.\n    // prevents us from having to query the metadata for all packages.\n    if ((filterByPatterns && filterByPatterns.length) || (flags && flags.pattern)) {\n      const filterByNames =\n        filterByPatterns && filterByPatterns.length\n          ? filterByPatterns.map(pattern => normalizePattern(pattern).name)\n          : [];\n      depReqPatterns = depReqPatterns.filter(\n        dep =>\n          filterByNames.indexOf(normalizePattern(dep.pattern).name) >= 0 ||\n          (flags && flags.pattern && micromatch.contains(normalizePattern(dep.pattern).name, flags.pattern)),\n      );\n    }\n\n    const deps = await Promise.all(\n      depReqPatterns.map(async ({pattern, hint, workspaceName, workspaceLoc}): Promise<Dependency> => {\n        const locked = lockfile.getLocked(pattern);\n        if (!locked) {\n          throw new MessageError(reporter.lang('lockfileOutdated'));\n        }\n\n        const {name, version: current} = locked;\n        let latest = '';\n        let wanted = '';\n        let url = '';\n\n        const normalized = normalizePattern(pattern);\n\n        if (getExoticResolver(pattern) || getExoticResolver(normalized.range)) {\n          latest = wanted = 'exotic';\n          url = normalized.range;\n        } else {\n          const registry = config.registries[locked.registry];\n\n          ({latest, wanted, url} = await registry.checkOutdated(config, name, normalized.range));\n        }\n","sourceCodeStart":391,"sourceCodeEnd":427,"githubUrl":"https://github.com/yarnpkg/yarn/blob/c2dda503f3759b5be5f0e24ecd9cf5c97a540147/src/package-request.js#L391-L427","documentation":"During dependency walk, lockfile.getLocked(pattern) returns null for a pattern that should have a lockfile entry. This means package.json declares a dependency whose pattern is absent from yarn.lock — the lockfile is stale relative to package.json.","triggerScenarios":"package.json was edited (deps added/changed/renamed) without regenerating yarn.lock, so a required pattern has no locked entry. getLocked returns falsy.","commonSituations":"Merging branches with conflicting yarn.lock changes; hand-editing yarn.lock; upgrading deps without running install; CI running outdated lockfile.","solutions":["Run yarn install to regenerate yarn.lock","If corruption persists, delete yarn.lock and run yarn install fresh","Ensure yarn.lock is committed and kept in sync after every package.json change"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Before running install, verify lockfile coverage\nconst lockfileObj = await lockfile.parseLockfile(filePath);\nconst declaredDeps = Object.keys(pkgJson.dependencies || {});\nconst missing = declaredDeps.filter(d => !lockfileObj[d] && !lockfile.getLocked(d));\nif (missing.length) {\n  console.warn('Lockfile is stale; patterns missing:', missing);\n}","typeGuard":"function isLockfileComplete(lockfile: object, patterns: string[]): boolean {\n  return patterns.every(p => lockfile.getLocked(p) != null);\n}","tryCatchPattern":"try {\n  await install(config);\n} catch (e) {\n  if (e.message.includes('Outdated lockfile')) {\n    // run yarn install --force to regenerate\n  }\n}","preventionTips":["Run yarn install whenever package.json changes","Never hand-edit yarn.lock","Keep yarn.lock under version control and resolve merge conflicts promptly"],"tags":["lockfile","sync","configuration"],"backgroundTag":null,"analyzedSha":"c2dda503f3759b5be5f0e24ecd9cf5c97a540147","analyzedAt":"2026-08-13T04:17:06.305Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}