pnpm/pnpm · error · PnpmError
LOCKFILE_NOT_FOUND
LOCKFILE_NOT_FOUND
Error message
No lockfile found
What it means
`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.
Source
Thrown at pnpm11/installing/commands/src/import/index.ts:139
// it should not influence the new one
await rimraf(path.join(opts.dir, WANTED_LOCKFILE))
const versionsByPackageNames = {}
let preferredVersions = {}
if (fs.existsSync(path.join(opts.dir, 'yarn.lock'))) {
const yarnPackageLockFile = await readYarnLockFile(opts.dir)
getAllVersionsFromYarnLockFile(yarnPackageLockFile, versionsByPackageNames)
} else if (
fs.existsSync(path.join(opts.dir, 'package-lock.json')) ||
fs.existsSync(path.join(opts.dir, 'npm-shrinkwrap.json'))
) {
const npmPackageLock = await readNpmLockfile(opts.dir)
if (npmPackageLock.lockfileVersion < 3) {
getAllVersionsByPackageNamesPreV3(npmPackageLock, versionsByPackageNames)
} else {
getAllVersionsByPackageNames(npmPackageLock, versionsByPackageNames)
}
} else {
throw new PnpmError('LOCKFILE_NOT_FOUND', 'No lockfile found')
}
preferredVersions = getPreferredVersions(versionsByPackageNames)
// For a workspace with shared lockfile
if (opts.workspaceDir) {
const allProjects = opts.allProjects ?? await findWorkspaceProjects(opts.workspaceDir, {
...opts,
patterns: opts.workspacePackagePatterns,
})
const selectedProjectsGraph = opts.selectedProjectsGraph ?? selectProjectByDir(allProjects, opts.dir)
if (selectedProjectsGraph != null) {
const sequencedGraph = sequenceGraph(selectedProjectsGraph)
// Check and warn if there are cyclic dependencies
if (!opts.ignoreWorkspaceCycles && !sequencedGraph.safe) {
const cyclicDependenciesInfo = sequencedGraph.cycles.length > 0
? `: ${sequencedGraph.cycles.map(deps => deps.join(', ')).join('; ')}`
: ''
View on GitHub (pinned to 5b11d3a15b)
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
Example fix
# before (cwd packages/web, lockfile at repo root) pnpm import # after cd /repo/root && pnpm import
Defensive patterns
Strategy: validation
Validate before calling
const fs = require('fs')
const foreign = ['yarn.lock', 'package-lock.json', 'npm-shrinkwrap.json']
.find(f => fs.existsSync(f))
if (!foreign) {
console.error('nothing to import; run from a directory with a yarn/npm lockfile')
process.exit(1)
} Prevention
- 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
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- YARN_LOCKFILE_PARSE_FAILED
- YARN_LOCKFILE_NOT_FOUND
- MISSING_HOISTED_LOCATIONS
- PATCH_FILE_PATH_MISSING
- CONFIG_CONFLICT_SHARED_WORKSPACE_LOCKFILE_WITH_GLOBAL
AI-assisted analysis of pnpm/pnpm@5b11d3a15b (2026-08-16).
Data as JSON: /api/errors/696171616945387b.
Report an issue: GitHub.