Skip to content

Repository files navigation

@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.

version build MIT License

Installation

npm i @alphahydrae/exec

Support matrix

OS & Architecture Node.js 22 Node.js 24 Node.js 26
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 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:

  • NAPI-RS (build pre-compiled Node.js addons in Rust)
  • nix (Rust-friendly bindings to the various *nix system functions)

About

The execvp function for Node.js

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages