# unwrap-npm-cmd

> Unwrap npm's node.js bin CMD batch for js files on Windows

Latest version **2.1.7** (published 2026-09-25) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install unwrap-npm-cmd
pnpm add unwrap-npm-cmd
yarn add unwrap-npm-cmd
bun add unwrap-npm-cmd
```

## Health

**Score 70/100 (B)** — status: active.

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

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 2.1.7 |
| Published | 2026-09-25 |
| First published | 2019-07-14 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | ^22.22.2 \|\| ^24.15.0 \|\| >=26.0.0 |
| Dependencies | 1 |
| Unpacked size | 19 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Joel Chen |
| Maintainers | jchip |
| Keywords | unwrap-npm-cmd, unwrap, npm, cmd, batch, windows |

## Links

- npm: https://www.npmjs.com/package/unwrap-npm-cmd
- Repository: https://github.com/jchip/fynjs
- Homepage: https://github.com/jchip/fynjs/tree/main/packages/unwrap-npm-cmd
- Issues: https://github.com/jchip/fynjs/issues
- npm.io page: https://npm.io/package/unwrap-npm-cmd

## Dependencies (1)

- [which](https://npm.io/package/which.md) ^6.0.1

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 2.1.7 (latest) — 2026-09-25
- 2.1.6 — 2026-09-24
- 2.1.5 — 2026-09-23
- 2.1.4 — 2026-09-19
- 2.1.3 — 2026-09-18
- 2.1.2 — 2026-09-11
- 2.1.1 — 2026-09-08
- 2.1.0 — 2026-09-06
- 2.0.0 — 2026-08-31
- 1.1.2 — 2025-06-03
- 1.1.1 — 2019-11-11
- 1.1.0 — 2019-07-14
- 1.0.0 — 2019-07-14

## README

# unwrap-npm-cmd

Unwrap npm's node.js bin CMD batch for js files on Windows.

[Sample](./test/fixtures/sample.js):

```js
const unwrapNpmCmd = require("unwrap-npm-cmd");
console.log(unwrapNpmCmd("npm test"));
console.log(unwrapNpmCmd("npx mocha", { relative: true }));
console.log(unwrapNpmCmd("mocha test", { jsOnly: true }));
console.log(unwrapNpmCmd(`find "name" package.json`));
console.log(unwrapNpmCmd("hello world", { path: __dirname }));
```

Output:

```cmd
"C:\Users\userid\nvm\nodejs\bin\node.exe" "C:\Users\userid\nvm\nodejs\bin\node_modules\npm\bin\npm-cli.js" test
"C:\Users\userid\nvm\nodejs\bin\node.exe" "..\nvm\nodejs\bin\node_modules\npm\bin\npx-cli.js" mocha
"C:\Users\userid\unwrap-npm-cmd\node_modules\mocha\bin\mocha" test
"C:\WINDOWS\system32\find.EXE" "name" package.json
"C:\Users\userid\unwrap-npm-cmd\test\fixtures\hello.CMD" world
```

## Usage

```js
child.spawnSync(unwrapNpmCmd("mocha test", { relative: true }));
```

Would effectivly be doing:

```js
child.spawnSync(
  `"C:\\Users\\userid\\nvm\\nodejs\\bin\\node.exe" ".\\node_modules\\mocha\\bin\\_mocha" test`
);
```

## API

```js
unwrapNpmCmd(cmd, options);
```

`options`:

| name       | description                                                |
| ---------- | ---------------------------------------------------------- |
| `path`     | Use instead of the `PATH` environment variable.            |
| `jsOnly`   | Return only the JS file as command without node exe.       |
| `relative` | Convert JS file to relative path from CWD.                 |
| `cwd`      | Use instead of `process.cwd()` to find relative path from. |

# License

Licensed under the [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0)

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