ps-node is a Node.js module designed for looking up and managing running processes across different operating systems. It leverages native system commands like `ps` on Linux/macOS and `wmic` on Windows to retrieve detailed process information, including PID, command, and arguments. The package, currently at version 0.1.6, was last published nine years ago. Its primary functionality includes searching for processes by PID or filtering by command and arguments using regular expressions. Additionally, it offers a `kill` function to terminate processes, supporting optional signals and timeouts. Due to its age, it does not support modern Node.js features like ECMAScript Modules (ESM) and is likely incompatible with recent Node.js versions or major operating system updates. There is no ongoing release cadence, and it is largely superseded by more actively maintained alternatives.
npm install ps-nodeVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use `ps-node` to find running Node.js processes with specific debug arguments and then, as an example, attempts to terminate the first matching process.
Consider using more modern and actively maintained alternatives like `ps-list` or `systeminformation` for process management in Node.js.
Thoroughly test on all target operating systems and versions. For production-critical applications, consider implementing fallback mechanisms or using a more robust native solution if available.
Always use string representations for signals when calling `ps.kill()` (e.g., `ps.kill(pid, 'SIGKILL', callback)`).
For Windows, carefully test the output accuracy of `command` and `arguments`. If precise command-line arguments are critical, `ps-node` might not be the most reliable solution, and a different library or direct `wmic`/`tasklist` invocation might be necessary. Note that some versions of `ps-node` (or forks) might concatenate command and arguments into a single string.
Ensure that the `ps` command (on Linux/macOS) or `wmic` (on Windows) is installed and accessible in the system's PATH. Check execution permissions for the Node.js process. On Windows, ensure `cmd` is available.
This package is not maintained, so direct fixes are unlikely. The best solution is to migrate to a more current process management library or implement custom parsing for the specific OS if `ps-node` is absolutely required.
Verify that the PID is correct and that the target process is still running. Ensure the Node.js application has the necessary permissions to send signals to other processes on the operating system.