# npm-to-yarn

> Convert npm CLI commands to Yarn commands, and vice versa

Latest version **3.2.0** (published 2026-07-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install npm-to-yarn
pnpm add npm-to-yarn
yarn add npm-to-yarn
bun add npm-to-yarn
```

## Health

**Score 60/100 (C)** — status: active.

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

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 3.2.0 |
| Published | 2026-07-24 |
| First published | 2020-03-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | ^12.22.0 \|\| ^14.17.0 \|\| >=16.0.0 |
| Dependencies | 0 |
| Unpacked size | 166 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 37 |
| Author | Ben Gubler |
| Maintainers | slorber, nebrelbug, bgub |
| Keywords | string convert, documentation, yarn to npm |

## Links

- npm: https://www.npmjs.com/package/npm-to-yarn
- Repository: https://github.com/nebrelbug/npm-to-yarn
- Homepage: https://github.com/nebrelbug/npm-to-yarn#readme
- Issues: https://github.com/nebrelbug/npm-to-yarn/issues
- Funding: https://github.com/nebrelbug/npm-to-yarn?sponsor=1
- npm.io page: https://npm.io/package/npm-to-yarn

## Alternatives

- [@cantoo/pdf-lib](https://npm.io/package/@cantoo/pdf-lib.md) — 297.9K weekly downloads
- [datatables.net-buttons](https://npm.io/package/datatables.net-buttons.md) — 200.1K weekly downloads
- [@ckeditor/ckeditor5-export-pdf](https://npm.io/package/@ckeditor/ckeditor5-export-pdf.md) — 167.0K weekly downloads
- [scanbot-web-sdk](https://npm.io/package/scanbot-web-sdk.md) — 15.0K weekly downloads
- [@syncfusion/ej2-angular-pdfviewer](https://npm.io/package/@syncfusion/ej2-angular-pdfviewer.md) — 8.8K weekly downloads

## Recent versions

- 3.2.0 (latest) — 2026-07-24
- 3.1.0 — 2026-07-20
- 3.0.1 — 2024-12-24
- 3.0.0 — 2024-08-29
- 2.2.1 — 2024-02-16
- 2.2.0 — 2024-02-15
- 2.1.0 — 2023-09-06
- 2.0.0 — 2023-02-20
- 1.3.0 — 2023-02-09
- 1.2.1 — 2022-12-19
- 1.2.0 — 2022-12-17
- 1.1.0 — 2022-12-17
- 1.0.1 — 2020-05-04
- 1.0.0-2 — 2020-03-20
- 1.0.0-1 — 2020-03-19
- … 1 more at https://npm.io/package/npm-to-yarn/versions

## README

# npm-to-yarn

<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->

[logo]: https://img.shields.io/badge/all_contributors-0-orange.svg 'Number of contributors on All-Contributors'

<!-- ALL-CONTRIBUTORS-BADGE:END -->

[![npm](https://img.shields.io/npm/v/npm-to-yarn)](https://www.npmjs.com/package/npm-to-yarn)
[![License](https://img.shields.io/npm/l/npm-to-yarn)](./LICENSE)
[![CI](https://github.com/nebrelbug/npm-to-yarn/actions/workflows/ci.yml/badge.svg)](https://github.com/nebrelbug/npm-to-yarn/actions/workflows/ci.yml)
[![Coveralls](https://img.shields.io/coveralls/nebrelbug/npm-to-yarn.svg)](https://coveralls.io/github/nebrelbug/npm-to-yarn)

[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
[![Donate](https://img.shields.io/badge/donate-paypal-blue.svg)](https://paypal.me/bengubler)

**Summary**

`npm-to-yarn` is designed to convert NPM CLI commands to their Yarn equivalents (and vice versa).

## Why `npm-to-yarn`?

`npm-to-yarn` is super helpful in documentation, for example in generating code tabs.

## 📜 Docs

```js
import convert from 'npm-to-yarn'

// or
// var convert = require('npm-to-yarn')

convert('npm install squirrelly', 'yarn')
// yarn add squirrelly

convert('npm install squirrelly', 'deno')
// deno add squirrelly

convert('npm install squirrelly', 'nub')
// nub add squirrelly

// npx conversions

convert('npx create-next-app', 'yarn')
// yarn dlx create-next-app

convert('npx create-next-app', 'deno')
// deno x create-next-app

convert('npx create-next-app', 'nub')
// nubx create-next-app
```

`npm-to-yarn` exposes a UMD build, so you can also install it with a CDN (it exposes global variable `n2y`)

### API

```ts
/**
 * Converts between npm and yarn command
 */
export default function convert (str: string, to: 'npm' | 'yarn' | 'pnpm' | 'bun' | 'deno' | 'nub'): string
```

## ✔️ Tests

Tests can be run with `npm test`. Multiple tests check that parsing, rendering, and compiling return expected results, formatting follows guidelines, and code coverage is at the expected level.

## 📦 Contributing to `npm-to-yarn` - Setup Guide

Install Dependencies

```sh copy
npm install
```

Run the development server

```sh
npm run start
```

A new file: `npm-to-yarn.mjs` is created in `dist` folder. <br>
Open `node` inside the terminal and write the following code to test new changes

```js
const npmToYarn = await import('./dist/npm-to-yarn.mjs')
const convert = npmToYarn.default

convert('npm install react', 'bun')
```

## Resources

To be added

## Projects using `npm-to-yarn`

- [Dynamoose](https://dynamoosejs.com)
- [Docusaurus](https://docusaurus.io)

## Contributors

Made with ❤ by [@nebrelbug](https://github.com/nebrelbug) and all these wonderful contributors ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)):

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->


<!-- markdownlint-enable -->
<!-- prettier-ignore-end -->

<!-- ALL-CONTRIBUTORS-LIST:END -->

This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind are welcome!

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