
Security News
MCP Community Begins Work on Official MCP Metaregistry
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
find-process
Advanced tools
The find-process npm package is a utility that allows users to find and list processes running on the system based on a given query, such as process name, port, or process ID. It provides a simple and efficient way to retrieve information about system processes, which can be useful for monitoring and management tasks in Node.js applications.
Find process by name
This feature allows users to find processes by their name. The code sample demonstrates how to use find-process to search for all processes with the name 'node'. The function returns a promise that resolves to a list of processes matching the query.
const find = require('find-process');
find('name', 'node').then(function (list) {
console.log(list);
});
Find process by port
This feature enables users to find processes using a specific port. In the provided code, find-process is used to search for any process that is using port 8080. The result is a list of processes that are returned after the promise resolves.
const find = require('find-process');
find('port', 8080).then(function (list) {
console.log(list);
});
Find process by pid
This functionality allows the user to find a process by its process ID (pid). The code example shows how to find a process with the pid 12345. The function returns a promise that provides the details of the process if found.
const find = require('find-process');
find('pid', 12345).then(function (list) {
console.log(list);
});
ps-node is a package similar to find-process that allows for searching, looking up, and killing processes. It provides a broader API for process management compared to find-process, including the ability to kill processes.
pidusage is another package that provides information about running processes, such as CPU and memory usage statistics. While it focuses more on performance metrics rather than just finding processes, it serves a complementary role to find-process.
With find-process, you can:
We have covered the difference of main OS platform, including Mac OSX, Linux, Windows and Android (with Termux).
Install find-process as a CLI tool:
$ npm install find-process -g
Usage:
Usage: find-process [options] <keyword>
Options:
-V, --version output the version number
-t, --type <type> find process by keyword type (pid|port|name)
-p, --port find process by port
-h, --help output usage information
Examples:
$ find-process node # find by name "node"
$ find-process 111 # find by pid "111"
$ find-process -p 80 # find by port "80"
$ find-process -t port 80 # find by port "80"
Example:
You can use npm to install:
$ npm install find-process --save
Usage:
const find = require('find-process');
find('pid', 12345)
.then(function (list) {
console.log(list);
}, function (err) {
console.log(err.stack || err);
})
Promise<Array> find(type, value, [options])
Arguments
type
the type of find, support: port|pid|namevalue
the value of type, can be RegExp if type is nameoptions
this can either be the object described below or boolean to just set strict mode
options.strict
the optional strict mode is for checking port, pid, or name exactly matches the given one. (on Windows, .exe
can be omitted)options.logLevel
set the logging level to trace|debug|info|warn|error
. In practice this lets you silence a netstat warning on Linux.Return
The return value of find-process is Promise, if you use co you can use yield find(type, value)
directly.
The resolved value of promise is an array list of process ([]
means it may be missing on some platforms):
[{
pid: <process id>,
ppid: [parent process id],
uid: [user id (for *nix)],
gid: [user group id (for *nix)],
name: <command/process name>,
bin: <execute path (for *nix)>,
cmd: <full command with args>
}, ...]
Find process which is listening port 80.
const find = require('find-process');
find('port', 80)
.then(function (list) {
if (!list.length) {
console.log('port 80 is free now');
} else {
console.log('%s is listening port 80', list[0].name);
}
})
Find process by pid.
const find = require('find-process');
find('pid', 12345)
.then(function (list) {
console.log(list);
}, function (err) {
console.log(err.stack || err);
});
Find all nginx process.
const find = require('find-process');
find('name', 'nginx', true)
.then(function (list) {
console.log('there are %s nginx process(es)', list.length);
});
Find all nginx processes on Linux without logging a warning when run as a user who isn't root.
const find = require('find-process');
find('name', 'nginx', {strict: true, logLevel: 'error'})
.then(function (list) {
console.log('there are %s nginx process(es)', list.length);
});
We're welcome to receive Pull Request of bugfix or new feature, but please check the list before sending PR:
FAQs
find process info by port/pid/name etc.
We found that find-process demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
Research
Security News
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.
Research
Security News
Malicious npm packages posing as developer tools target macOS Cursor IDE users, stealing credentials and modifying files to gain persistent backdoor access.