{"id":13348,"library":"is-running","title":"Process Running Status","description":"The `is-running` package provides a minimalist and direct utility for Node.js environments to ascertain if a process with a specific Process ID (PID) is currently active on the system. As of its latest stable release, `2.1.0`, the library focuses on a single, clear function: returning a boolean indicating the presence of a process for a given PID. The package maintains a stable, albeit infrequent, release cadence, with its core functionality having remained consistent since its last major update. Its primary differentiator lies in its extreme simplicity and lack of external dependencies for runtime, making it a lightweight choice for basic process monitoring or cleanup tasks, especially when compared to more comprehensive process management libraries that offer broader control and information beyond just status checks.","status":"maintenance","version":"2.1.0","language":"javascript","source_language":"en","source_url":"git://github.com/nisaacson/is-running","tags":["javascript","pid","running","child","exec","spawn"],"install":[{"cmd":"npm install is-running","lang":"bash","label":"npm"},{"cmd":"yarn add is-running","lang":"bash","label":"yarn"},{"cmd":"pnpm add is-running","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The package exports a default function. While primarily a CommonJS module, Node.js can typically handle a default `import` statement for such modules. Direct named imports (`{ isrunning }`) will not work as it does not expose named exports.","wrong":"import { isrunning } from 'is-running';","symbol":"isrunning","correct":"import isrunning from 'is-running';"},{"note":"This is the original and intended way to use the CommonJS module.","symbol":"isrunning","correct":"const isrunning = require('is-running');"},{"note":"The package is a CommonJS module. While `import` syntax may work in environments configured for interoperability or transpilation, `require()` is the native and most robust method. TypeScript users might need `esModuleInterop: true` in `tsconfig.json` for `import` syntax or use `import = require()`.","wrong":"import isrunning from 'is-running'; // May require 'type: module' or transpilation\nimport { default as isrunning } from 'is-running'; // Not typically required for default exports","symbol":"isrunning","correct":"const isrunning = require('is-running');\n// Or for TypeScript without explicit ESM config:\n// import isrunning = require('is-running');"}],"quickstart":{"code":"const isrunning = require('is-running');\n\n// Example PID (replace with a known running process on your system)\n// On Unix-like: `ps aux` to find a PID, e.g., '1'\n// On Windows: `tasklist` to find a PID, e.g., '4'\nconst testPid = process.platform === 'win32' ? 4 : 1; // PID 1 is usually init/systemd on Linux, PID 4 System on Windows\n\nif (isrunning(testPid)) {\n  console.log(`Process with PID ${testPid} is running.`);\n} else {\n  console.log(`No process found with PID ${testPid}.`);\n}\n\n// Test a non-existent PID (e.g., a very high number)\nconst nonExistentPid = 999999; \nif (isrunning(nonExistentPid)) {\n  console.log(`Process with PID ${nonExistentPid} is running.`);\n} else {\n  console.log(`No process found with PID ${nonExistentPid}.`);\n}","lang":"javascript","description":"This quickstart demonstrates how to import and use the `is-running` function to check the status of a process by its PID, including a cross-platform example for common system processes and a check for a non-existent PID."},"warnings":[{"fix":"For CommonJS projects, use `const isrunning = require('is-running');`. For ESM projects, consider dynamic import `import('is-running').then(mod => mod.default(pid))` or ensure your build setup correctly handles CommonJS module imports.","message":"The package's latest version (2.1.0) was released in 2016. It primarily supports CommonJS modules. Modern Node.js projects using ESM (`\"type\": \"module\"` in `package.json`) might encounter issues with direct `import` statements without proper transpilation or Node.js's CJS-ESM interop features.","severity":"gotcha","affected_versions":"<=2.1.0"},{"fix":"Ensure the Node.js process has appropriate permissions to query system process tables. For critical applications, wrap calls in `try-catch` blocks and implement robust error handling and logging.","message":"The functionality of `is-running` relies on operating system specifics for checking process IDs. While generally reliable, edge cases or permission restrictions on certain systems might lead to unexpected results or errors if Node.js lacks the necessary permissions to query process information.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Avoid using `is-running` to determine the existence of privileged or critical system processes (like PID 0 or 4 on Windows) for the purpose of termination or manipulation. Focus on userland processes or processes started by your application.","message":"On Windows, PID 0 and 4 are special (Idle and System processes, respectively). While `is-running` might return true for these, directly interacting with them via signals (e.g., `process.kill`) is generally not advisable and may not behave as expected or be permitted.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Ensure you are importing the default export correctly: `const isrunning = require('is-running');` or `import isrunning from 'is-running';` (for ESM-enabled environments).","cause":"Attempting to call `isrunning` after importing it incorrectly as a named export from a CommonJS module, or calling a property of the imported module rather than the module itself.","error":"TypeError: isrunning is not a function"},{"fix":"For `is-running`, it's a CommonJS module, so `require('is-running')` is the correct method. If you are in an ESM context (`\"type\": \"module\"` in `package.json`), `import isrunning from 'is-running';` should work due to Node.js interoperability, but if not, consider `const isrunning = await import('is-running').then(mod => mod.default);` or review your `tsconfig.json` for `esModuleInterop`.","cause":"Attempting to `require()` an ESM-only module, or using `import` in a CommonJS context without proper configuration, although `is-running` itself is CJS. This error might occur in reverse if a user tries to `import` `is-running` in an ESM context and the module resolution fails, especially if a custom resolver or bundler is involved that expects `\"type\": \"module\"`.","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module ... from ... not supported."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null}