# lpm migrate (/docs/packages/migrate)



```bash
lpm migrate
```

Detects which package manager a project currently uses, parses the foreign lockfile, converts it to `lpm.lock` plus `lpm.lockb` when the graph fits the binary format, optionally configures `.npmrc`, runs `lpm install` against the new lockfile, and (optionally) verifies that `build` + `test` scripts still pass.

`lpm migrate` is non-destructive: every file it touches is backed up first (`package-lock.json.backup`, `.npmrc.backup`, etc.), and `--rollback` restores them.

## Examples [#examples]

```bash
lpm migrate                  # default — non-interactive
lpm migrate --dry-run        # parse + convert, write nothing
lpm migrate --force          # overwrite an existing lpm.lock
lpm migrate --no-install     # convert lockfile only, don't install
lpm migrate --skip-verify    # skip the build/test verification step
lpm migrate --no-npmrc       # don't touch .npmrc
lpm migrate --ci             # also generate a CI workflow template
lpm migrate --rollback       # restore from .backup files
```

The flow is non-interactive — there are no prompts to skip and `-y` is reserved for a future interactive mode. Pass `--force` if you want to overwrite an existing `lpm.lock`.

## What runs, in order [#what-runs-in-order]

1. **Pre-flight** — confirm `package.json` exists; refuse if `lpm.lock` already exists (unless `--force` or `--dry-run`).
2. **Detect + parse + convert** — identify source PM (npm / pnpm / yarn / bun), read its lockfile, convert to LPM CLI format.
3. **Translate `pnpm.*` blocks** — auto-translate `pnpm.overrides`, `pnpm.patchedDependencies`, and `pnpm.peerDependencyRules` into the matching `lpm.*` fields. Patch translations also add `lpm.lock > [patches]` checksum records. Validation runs up-front: range parse errors, conflicting keys / ranges, unsupported value shapes, missing patch integrity bindings — all surface BEFORE any disk mutation. The original `pnpm.*` block stays in place after migration so a parallel `pnpm install` keeps working during the transition. See [Migrating from pnpm](/docs/guides/migrating-from-pnpm) for per-block details.
4. **Write** — emit `lpm.lock` and, when supported by the binary format, `lpm.lockb`. Back up the source lockfile, the existing `lpm.lock` / `lpm.lockb` (if any), `.gitattributes`, and — when the `pnpm.*` translations have entries to apply — `package.json` plus any patch destinations the migration is about to clobber.
5. **`.npmrc`** — optionally append `@lpm.dev:registry=https://lpm.dev/api/registry/` to `.npmrc` (or create one). Backs up the original on touch. **No-op** if the file already declares an `@lpm.dev:registry` scope. Skip the whole step with `--no-npmrc`.
6. **Install** — run `lpm install` against the new lockfile (lockfile fast-path, no re-resolution). Skip with `--no-install`.
7. **Verify** — run `build` + `test` scripts to confirm nothing broke. Skip with `--skip-verify`.
8. **CI template** — print a hint pointing at a CI workflow template, or generate one with `--ci`. Suppress with `--no-ci`.
9. **Completion** — print a compact status transcript: detected source + backup reminder, converted lockfile outputs, any install/verify phases, then `Done · migration completed successfully`.

## Rollback [#rollback]

If anything goes wrong (or the migration was a mistake), restore in one command:

```bash
lpm migrate --rollback
```

Walks the backups created by the previous migration and restores them in place. Safe to run repeatedly.

## Flags [#flags]

| Flag            | Effect                                                                                             |
| --------------- | -------------------------------------------------------------------------------------------------- |
| `--dry-run`     | Parse and convert only — write nothing                                                             |
| `--force`       | Overwrite an existing `lpm.lock`                                                                   |
| `-y`, `--yes`   | Reserved. The flow is non-interactive today, so this flag is a no-op. It does NOT imply `--force`. |
| `--no-install`  | Don't run `lpm install` after conversion                                                           |
| `--skip-verify` | Skip the build/test verification step                                                              |
| `--no-npmrc`    | Don't touch `.npmrc`                                                                               |
| `--ci`          | Generate a CI workflow template for the detected platform                                          |
| `--no-ci`       | Suppress the CI template hint                                                                      |
| `--rollback`    | Restore files from `.backup` copies created by a previous migration                                |

Plus the [global flags](/docs/commands#global-flags).

## See also [#see-also]

* [Migrating from npm](/docs/guides/migrating-from-npm)
* [Migrating from pnpm](/docs/guides/migrating-from-pnpm)
* [Migrating from Yarn](/docs/guides/migrating-from-yarn)
* [Migrating from Bun](/docs/guides/migrating-from-bun)
* [`lpm install`](/docs/packages/install) — runs after conversion to materialize `node_modules`
* [Lockfile](/docs/packages/lockfile) — `lpm.lock` and `lpm.lockb` formats
