{"record":{"id":"833b4247ceb90fe6","repo":"yarnpkg/yarn","slug":"norequiredlockfile","errorCode":null,"errorMessage":"noRequiredLockfile","messagePattern":"noRequiredLockfile","errorType":"exception","errorClass":"MessageError","httpStatus":null,"severity":"error","filePath":"src/cli/index.js","lineNumber":561,"sourceCode":"      ignoreEngines: commander.ignoreEngines,\n      ignoreScripts: commander.ignoreScripts,\n      offline: commander.preferOffline || commander.offline,\n      looseSemver: !commander.strictSemver,\n      production: commander.production,\n      httpProxy: commander.proxy,\n      httpsProxy: commander.httpsProxy,\n      registry: commander.registry,\n      networkConcurrency: commander.networkConcurrency,\n      networkTimeout: commander.networkTimeout,\n      nonInteractive: commander.nonInteractive,\n      updateChecksums: commander.updateChecksums,\n      focus: commander.focus,\n      otp: commander.otp,\n    })\n    .then(() => {\n      // lockfile check must happen after config.init sets lockfileFolder\n      if (command.requireLockfile && !fs.existsSync(path.join(config.lockfileFolder, constants.LOCKFILE_FILENAME))) {\n        throw new MessageError(reporter.lang('noRequiredLockfile'));\n      }\n\n      // option \"no-progress\" stored in yarn config\n      const noProgressConfig = config.registries.yarn.getOption('no-progress');\n\n      if (noProgressConfig) {\n        reporter.disableProgress();\n      }\n\n      // verbose logs outputs process.uptime() with this line we can sync uptime to absolute time on the computer\n      reporter.verbose(`current time: ${new Date().toISOString()}`);\n\n      const mutex: mixed = commander.mutex;\n      if (mutex && typeof mutex === 'string') {\n        const separatorLoc = mutex.indexOf(':');\n        let mutexType;\n        let mutexSpecifier;\n        if (separatorLoc === -1) {","sourceCodeStart":543,"sourceCodeEnd":579,"githubUrl":"https://github.com/yarnpkg/yarn/blob/c2dda503f3759b5be5f0e24ecd9cf5c97a540147/src/cli/index.js#L543-L579","documentation":"Thrown during CLI startup after `config.init` completes. When a command declares `requireLockfile: true` (e.g. `yarn install --frozen-lockfile`, `yarn check`, `yarn pack` in CI), Yarn checks that `yarn.lock` exists in `config.lockfileFolder`. If the file is absent the command aborts because it cannot proceed deterministically without a lockfile.","triggerScenarios":"Running any command whose `Command` definition sets `requireLockfile = true` in a directory that has never had `yarn install` run (no yarn.lock generated yet). Also `--frozen-lockfile` in a fresh CI checkout before the lockfile is committed.","commonSituations":"CI pipeline runs `yarn install --frozen-lockfile` but yarn.lock was gitignored or never committed. A fresh clone with no prior install. A command like `yarn check` run before the first `yarn install`.","solutions":["Run `yarn install` once without `--frozen-lockfile` to generate yarn.lock, then commit it.","Ensure yarn.lock is tracked in version control (remove it from .gitignore).","If the lockfile was deleted, restore it from git: `git checkout -- yarn.lock`.","Drop the `--frozen-lockfile` / `requireLockfile` flag for the first install on a clean environment."],"exampleFix":"# before (CI step, fails on fresh checkout)\nyarn install --frozen-lockfile\n# after (generate lockfile first, then freeze)\nyarn install\ngit add yarn.lock\n# subsequent CI runs:\nyarn install --frozen-lockfile","handlingStrategy":"validation","validationCode":"const fs = require('fs');\nconst path = require('path');\nconst lockfilePath = path.join(config.lockfileFolder, 'yarn.lock');\nif (command.requireLockfile && !fs.existsSync(lockfilePath)) {\n  // generate lockfile first instead of failing\n  console.error('yarn.lock missing — run `yarn install` without --frozen-lockfile first.');\n  process.exit(1);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await runCommand();\n} catch (err) {\n  if (err instanceof MessageError && err.message === reporter.lang('noRequiredLockfile')) {\n    // fall back to a non-frozen install to generate the lockfile\n    await exec('yarn install');\n  } else {\n    throw err;\n  }\n}","preventionTips":["Commit yarn.lock to version control and never gitignore it.","In CI, generate the lockfile once (or assert it is present) before using --frozen-lockfile.","Gate requireLockfile commands behind a `fs.existsSync(lockfilePath)` check in wrapper scripts."],"tags":["lockfile","ci","install"],"backgroundTag":null,"analyzedSha":"c2dda503f3759b5be5f0e24ecd9cf5c97a540147","analyzedAt":"2026-08-13T04:17:06.305Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}