{"record":{"id":"696171616945387b","repo":"pnpm/pnpm","slug":"lockfile-not-found","errorCode":"LOCKFILE_NOT_FOUND","errorMessage":"No lockfile found","messagePattern":"No lockfile found","errorType":"exception","errorClass":"PnpmError","httpStatus":null,"severity":"error","filePath":"pnpm11/installing/commands/src/import/index.ts","lineNumber":139,"sourceCode":"  // it should not influence the new one\n  await rimraf(path.join(opts.dir, WANTED_LOCKFILE))\n  const versionsByPackageNames = {}\n  let preferredVersions = {}\n  if (fs.existsSync(path.join(opts.dir, 'yarn.lock'))) {\n    const yarnPackageLockFile = await readYarnLockFile(opts.dir)\n    getAllVersionsFromYarnLockFile(yarnPackageLockFile, versionsByPackageNames)\n  } else if (\n    fs.existsSync(path.join(opts.dir, 'package-lock.json')) ||\n    fs.existsSync(path.join(opts.dir, 'npm-shrinkwrap.json'))\n  ) {\n    const npmPackageLock = await readNpmLockfile(opts.dir)\n    if (npmPackageLock.lockfileVersion < 3) {\n      getAllVersionsByPackageNamesPreV3(npmPackageLock, versionsByPackageNames)\n    } else {\n      getAllVersionsByPackageNames(npmPackageLock, versionsByPackageNames)\n    }\n  } else {\n    throw new PnpmError('LOCKFILE_NOT_FOUND', 'No lockfile found')\n  }\n  preferredVersions = getPreferredVersions(versionsByPackageNames)\n\n  // For a workspace with shared lockfile\n  if (opts.workspaceDir) {\n    const allProjects = opts.allProjects ?? await findWorkspaceProjects(opts.workspaceDir, {\n      ...opts,\n      patterns: opts.workspacePackagePatterns,\n    })\n    const selectedProjectsGraph = opts.selectedProjectsGraph ?? selectProjectByDir(allProjects, opts.dir)\n    if (selectedProjectsGraph != null) {\n      const sequencedGraph = sequenceGraph(selectedProjectsGraph)\n      // Check and warn if there are cyclic dependencies\n      if (!opts.ignoreWorkspaceCycles && !sequencedGraph.safe) {\n        const cyclicDependenciesInfo = sequencedGraph.cycles.length > 0\n          ? `: ${sequencedGraph.cycles.map(deps => deps.join(', ')).join('; ')}`\n          : ''\n","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/pnpm/pnpm/blob/5b11d3a15b9022a2109cb18ed96a5d652630371f/pnpm11/installing/commands/src/import/index.ts#L121-L157","documentation":"`pnpm import` converts an existing foreign lockfile (yarn.lock v1 or 2+, or package-lock.json / npm-shrinkwrap.json) into pnpm-lock.yaml, deleting any existing wanted lockfile first. If none of those files exists in the target directory, there is nothing to import and the handler throws LOCKFILE_NOT_FOUND.","triggerScenarios":"Running `pnpm import` in a directory holding no yarn.lock, package-lock.json, or npm-shrinkwrap.json, including when the lockfile sits in a parent directory (monorepo root) while cwd is a subproject, or the lockfile comes from an unsupported tool (bun.lockb).","commonSituations":"Migrating a repo whose lockfile lives at the root while import ran in a package dir; an already-migrated repo; a lockfile renamed or generated by another tool.","solutions":["Run `pnpm import` from the directory that contains yarn.lock or package-lock.json, usually the repo root","Generate the foreign lockfile first if missing: `npm install --package-lock-only` or `yarn install`","Bun and pnpm lockfiles are not importable; migrate with the tool that owns them"],"exampleFix":"# before (cwd packages/web, lockfile at repo root)\npnpm import\n\n# after\ncd /repo/root && pnpm import","handlingStrategy":"validation","validationCode":"const fs = require('fs')\nconst foreign = ['yarn.lock', 'package-lock.json', 'npm-shrinkwrap.json']\n  .find(f => fs.existsSync(f))\nif (!foreign) {\n  console.error('nothing to import; run from a directory with a yarn/npm lockfile')\n  process.exit(1)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run import from the repo root where the foreign lockfile lives","Generate the lockfile first (npm i --package-lock-only / yarn install) in fresh repos","Check file names before migrating; bun/pnpm lockfiles are not importable"],"tags":["import","lockfile","migration","npm","yarn"],"backgroundTag":null,"analyzedSha":"5b11d3a15b9022a2109cb18ed96a5d652630371f","analyzedAt":"2026-08-16T13:18:59.198Z","schemaVersion":2},"datasetVersion":"2026-08-16T18:17:16.020Z"}