# npm-migrate-all

> Migrate all versions of given npm package to another registry.

Latest version **0.3.0** (published 2024-01-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install npm-migrate-all
pnpm add npm-migrate-all
yarn add npm-migrate-all
bun add npm-migrate-all
```

Provides the command `npm-migrate-all`.

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.0 |
| Published | 2024-01-16 |
| First published | 2022-07-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 12 |
| Unpacked size | 40.4 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 3 |
| Author | banyudu |
| Maintainers | banyudu |
| Keywords | npm, migrate, verdaccio |

## Links

- npm: https://www.npmjs.com/package/npm-migrate-all
- Repository: https://github.com/banyudu/npm-migrate-all
- Homepage: https://github.com/banyudu/npm-migrate-all#readme
- Issues: https://github.com/banyudu/npm-migrate-all/issues
- npm.io page: https://npm.io/package/npm-migrate-all

## Dependencies (12)

- [i](https://npm.io/package/i.md) ^0.3.7
- [zx](https://npm.io/package/zx.md) ^7.0.7
- [npm](https://npm.io/package/npm.md) ^8.13.2
- [lodash](https://npm.io/package/lodash.md) ^4.17.21
- [p-limit](https://npm.io/package/p-limit.md) ^4.0.0
- [progress](https://npm.io/package/progress.md) 2
- [tar-stream](https://npm.io/package/tar-stream.md) ^2.2.0
- [gunzip-maybe](https://npm.io/package/gunzip-maybe.md) ^1.4.2
- [@types/p-limit](https://npm.io/package/@types/p-limit.md) ^2.2.0
- [multi-progress](https://npm.io/package/multi-progress.md) ^4.0.0
- [stream-to-string](https://npm.io/package/stream-to-string.md) ^1.2.0
- [stream-to-promise](https://npm.io/package/stream-to-promise.md) ^3.0.0

## Recent versions

- 0.3.0 (latest) — 2024-01-16
- 0.2.7 — 2023-06-19
- 0.2.6 — 2022-08-09
- 0.2.5 — 2022-08-09
- 0.2.4 — 2022-08-09
- 0.2.3 — 2022-08-09
- 0.2.2 — 2022-07-29
- 0.2.1 — 2022-07-29
- 0.2.0 — 2022-07-29
- 0.1.5 — 2022-07-27
- 0.1.4 — 2022-07-11
- 0.1.3 — 2022-07-11
- 0.1.2 — 2022-07-11
- 0.1.1 — 2022-07-11
- 0.1.0 — 2022-07-11
- … 1 more at https://npm.io/package/npm-migrate-all/versions

## README

# npm-migrate-all

Migrate all versions of given npm package to another registry.

## Install

```bash
npm i npm-migrate-all
```

## Usage

```typescript
import npmMigrateAll from 'npm-migrate-all'

const from = 'https://registry.npmjs.org/'  // source registry url
const to = 'http://localhost:4873/' // target registry url
const pkgs = ['pkg1', '@my/pkg2', 'pkg3@0.1.0']

npmMigrateAll(from, to, pkgs).then(({
  succeeded, // ['pkg1@0.0.1', 'pkg1@0.0.2']
  failed,
  skipped,
}) => {
  // migrated
})
```

## Cli Usage

```bash
npx npm-migrate-all --from=https://registry.npmjs.org/ --to=http://localhost:4873/ pkg1 @my/pkg2 pkg3@0.1.0
```

If you'd like to adjust concurreny limit, set environment variable `META_RATE_LIMIT`, `PACKAGE_RATE_LIMIT`, `VERSION_RATE_LIMIT` to the value as you wish.

```bash
# META_RATE_LIMIT default value 10
# PACKAGE_RATE_LIMIT default value 5
# VERSION_RATE_LIMIT default value 10
META_RATE_LIMIT=10 PACKAGE_RATE_LIMIT=5 VERSION_RATE_LIMIT=10 npx npm-migrate-all --from=https://registry.npmjs.org/ --to=http://localhost:4873/ pkg1 @my/pkg2 pkg3@0.1.0
```

## Explain

`npm-migrate-all` calls `npm` cli tool behind the scenes, with a limited concurrency (default 20).

```bash
# 1. fetch metadata
npm show pkg # get package metadata and tarball url.

# 2. download tarball via `npm pack`.
# 3. update package.json if needed.
# 4. save tarball to hard disk

# 5. publish to new registry
npm publish <path-to-tarball>
```

## Known issues

`npm-migrate-all`` will make every effort to migrate the package as is, meaning that the package's dist-tag and shasum will remain unchanged in most cases. However, this becomes impossible when an unscoped package's package.json file contains the publishConfig.registry field.

```json
{
  "publishConfig": {
    "registry": "https://registry.npmjs.org/"
  }
}
```

Npm does not permit command line parameters to override publishConfig in package.json, and .npmrc can only update the registry for scoped packages. Therefore, there is no way to publish an unscoped package without modifying its `package.json` file.

To resolve this issue, `npm-migrate-all` opens the tgz file in memory and updates the content of the package.json file. As a result of this operation, the tgz file's shasum will be altered.

---
_Source: https://npm.io/package/npm-migrate-all · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
