# npm-confirm

> Confirm your package manager before running NPM install!

Latest version **2.0.0** (published 2024-07-27) · GPL-3.0 license · 0 weekly downloads

## Install

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

Provides the command `npmc`.

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2024-07-27 |
| First published | 2024-04-02 |
| Weekly downloads | 0 |
| License | GPL-3.0 |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 406.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 23 |
| Author | EvanZhouDev |
| Maintainers | evanzhoudev |
| Keywords | npm, bun, pnpm, yarn |

## Links

- npm: https://www.npmjs.com/package/npm-confirm
- Repository: https://github.com/EvanZhouDev/npm-confirm
- Issues: https://github.com/EvanZhouDev/npm-confirm/issues
- npm.io page: https://npm.io/package/npm-confirm

## Dependencies (3)

- [chalk](https://npm.io/package/chalk.md) ^5.3.0
- [execa](https://npm.io/package/execa.md) ^8.0.1
- [@inquirer/select](https://npm.io/package/@inquirer/select.md) ^2.2.1

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 2.0.0 (latest) — 2024-07-27
- 1.0.0 — 2024-04-02

## README

![npm Confirm Banner](./art/banner.png)

<p align="center">
Use the right JS package manager without thinking.
<br>
<a href="#installation">Installation</a> | <a href="#features">Features</a>
</p>

## What is `npmc`?

`npmc` is a wrapper for the `npm` command that _confirms with you if it detects you using another package manager_.

When confirming, you can choose to do 3 things:

1. Run your command, [**adapted for the new package manager**](#automatic-command-adaptation)
2. Run your **original command**
3. **Cancel** the operation

Now, you can just copy and paste `npm install` commands from documentation without needing to manually edit the package manager!

<details>
<summary>Why not <code>@antfu/ni</code>?</summary>

When aliased to just `npm`, `npmc` serves as a quick way to run commands copied from external sources without needing to modify it at all, as opposed to `ni`, which reqires you to still swap out the `npm install` bit.

However, these tools can serve as compliments.

- If you are typing commands directly, you can still choose to use `ni`.
- You can use `npmc` in addition for copying and pasting or to catch occasional slipups.

</details>

## Installation

```bash
npm install -g npm-confirm
```

This will give you access to the `npmc` command, which acts like the `npm` command, but confirms with you.

I strongly recommend aliasing `npmc` to just `npm` so you can use `npm` like normal.

To do this in `zsh` or `bash` add this to your `.zshrc` or `.bashrc`:

```bash
alias npm='npmc'
```

<details>
<summary>Wrapping <code>pnpm</code>, <code>bun</code>, and <code>yarn</code></summary>

You may also want the `pnpm`, `bun`, and `yarn` commands to give confirmation when used with the wrong package manager.

By default, `npmc` acts as `npm` when no other package managers are detected. However, you can change that default by simply passing a `--[NAME]-alias` flag.

For example, if I run `npmc --pnpm-alias`, it will act as `pnpm` and confirm with you if you are using a non-`pnpm` package manager.

Again, I recommend aliasing these in `.zshrc`:

```bash
# npm
alias npm='npmc'

# pnpm
alias pnpm='npmc --pnpm-alias'

# bun
alias bun='npmc --bun-alias'

# yarn
alias yarn='npmc --yarn-alias'
```

</details>

## Features

### Automatic Command Adaptation

`npmc` will automatically adapt agent subcommands and flags from one package manager to the other.

For example, NPM's `ci` command will automagically be converted to `bun install --no-save` for Bun, and accordingly for other package managers.

### Command Preview

`npmc` always shows you what command will be run, both when using the adapted package manager, or even the one you ran the command with.

This maximizes transparency, and ensures `npmc` never does something you didn't mean when adapting commands.

Have a problem with command adaptation? Submit an issue!

### Smart Confirmations

`npmc` only confirms when you run certain commands, such as `install`, `uninstall`, `run`, `upgrade`, and their variants for the various package managers. This means that when you truly meant to use the other package manager, `npmc` will not stand in your way. Furthermore, all global installations are directly done directly with whatever you ran it with!

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