https://github.com/alphahydrae/node-exec
The execvp function for Node.js
https://github.com/alphahydrae/node-exec
exec execvp
Last synced: 4 months ago
JSON representation
The execvp function for Node.js
- Host: GitHub
- URL: https://github.com/alphahydrae/node-exec
- Owner: AlphaHydrae
- License: mit
- Created: 2025-02-01T14:12:05.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-05T00:30:56.000Z (over 1 year ago)
- Last Synced: 2025-03-29T08:23:27.679Z (about 1 year ago)
- Topics: exec, execvp
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/@alphahydrae/exec
- Size: 813 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# `@alphahydrae/exec`
The [`execvp` function](https://linux.die.net/man/3/execvp) for Node.js.
```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.
[](https://www.npmjs.com/package/@alphahydrae/exec)
[](https://github.com/AlphaHydrae/node-exec/actions/workflows/build.yml)
[](https://opensource.org/licenses/MIT)
- [Installation](#installation)
- [Support matrix](#support-matrix)
- [Credits](#credits)
## Installation
```bash
npm i @alphahydrae/exec
```
## Support 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 `exec` family of functions is part of the
> [POSIX](https://en.wikipedia.org/wiki/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:
- [A way to call execl, execle, execlp, execv, execvP or execvp from Node.js](https://stackoverflow.com/a/77774287/249893)
- [execve in node](https://groups.google.com/g/nodejs/c/4vtWG1KCQC4)
Also a big thank you to the following Rust projects for making it easy:
- [NAPI-RS](https://napi.rs) (build pre-compiled Node.js addons in Rust)
- [nix](https://docs.rs/nix) (Rust-friendly bindings to the various \*nix system functions)