Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/saltyshiomix/node-npx

A tiny npx alternative for Node.js, which executes local npm package binaries
https://github.com/saltyshiomix/node-npx

javascript nodejs npm npx typescript

Last synced: 10 days ago
JSON representation

A tiny npx alternative for Node.js, which executes local npm package binaries

Awesome Lists containing this project

README

        





Execute local npm package binaries like a npx for Node.js

## Install

```bash
$ npm install --save node-npx
```

## Usage

```js
// default import (asynchronously)
import npx from 'node-npx';

// named import is also supported
import { npx, npxSync } from 'node-npx';

// kill port 8080
const childProcess = npx('fkill', ['-f', ':8080'])
childProcess.on('exit', () => {
console.log('port 8080 was killed!')
})

// remove dist folder and list contents
npxSync('rimraf', ['dist']);
npxSync('glob', ['dist/**/*'], {
cwd: process.cwd(),
stdio: 'inherit',
});

// both relative and absolute paths are also supported
npxSync('./relative/path/to/my-binary');
npxSync('/absolute/path/to/my-binary');
```