2.0.0 • Published 7 months ago
@alphahydrae/exec v2.0.0
@alphahydrae/exec
The execvp function for Node.js.
import { execvp } from '@alphahydrae/exec';
execvp('ls', ['.']);
console.log(`
This will never print because the executing Node.js
program is replaced by the executed command, keeping
the same process ID and file descriptors.
`);If you're familiar with Bash's exec function, this is the same for Node.js.
This package was developed to be used in Node.js scripts that are frontends to execute other commands. For example, a script that would build and execute a complex SSH or Ansible command.
Installation
npm i @alphahydrae/execSupport matrix
| OS & Architecture | Node.js 20 | Node.js 22 | Node.js 24 |
|---|---|---|---|
| macOS x64 | ✅ | ✅ | ✅ |
| macOS arm64 | ✅ | ✅ | ✅ |
| Linux x64 gnu | ✅ | ✅ | ✅ |
| Linux x64 musl | ✅ | ✅ | ✅ |
| Linux arm64 gnu | ✅ | ✅ | ✅ |
| Linux arm64 musl | ✅ | ✅ | ✅ |
| Linux arm gnu | ❌ | ❌ | ❌ |
| Android arm64 | ❌ | ❌ | ❌ |
| Android armv7 | ❌ | ❌ | ❌ |
| FreeBSD x64 | ❌ | ❌ | ❌ |
| Windows x64 | ❌ | ❌ | ❌ |
| Windows x32 | ❌ | ❌ | ❌ |
| Windows arm64 | ❌ | ❌ | ❌ |
The
execfamily of functions is part of the POSIX operating system API, so it will not work on Windows.
Credits
This package is a re-implementation of https://github.com/jprichardson/node-kexec in Rust, also inspired by the following conversations:
Also a big thank you to the following Rust projects for making it easy: