{"id":13453865,"url":"https://github.com/mafintosh/why-is-node-running","last_synced_at":"2025-05-14T22:03:59.094Z","repository":{"id":40763044,"uuid":"51375640","full_name":"mafintosh/why-is-node-running","owner":"mafintosh","description":"Node is running but you don't know why? why-is-node-running is here to help you.","archived":false,"fork":false,"pushed_at":"2025-01-08T15:01:13.000Z","size":51,"stargazers_count":1903,"open_issues_count":9,"forks_count":46,"subscribers_count":18,"default_branch":"master","last_synced_at":"2025-05-07T21:13:52.234Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mafintosh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"mafintosh"}},"created_at":"2016-02-09T15:29:28.000Z","updated_at":"2025-05-07T02:25:54.000Z","dependencies_parsed_at":"2024-06-18T11:21:32.420Z","dependency_job_id":"5a1118ab-f5bb-4318-acea-19b5c92e5b7a","html_url":"https://github.com/mafintosh/why-is-node-running","commit_stats":{"total_commits":64,"total_committers":16,"mean_commits":4.0,"dds":0.5625,"last_synced_commit":"37b48fbc9f572ffae1d3df130db69ff4e48e8f70"},"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mafintosh%2Fwhy-is-node-running","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mafintosh%2Fwhy-is-node-running/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mafintosh%2Fwhy-is-node-running/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mafintosh%2Fwhy-is-node-running/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mafintosh","download_url":"https://codeload.github.com/mafintosh/why-is-node-running/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253997907,"owners_count":21996962,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T08:00:48.668Z","updated_at":"2025-05-14T22:03:59.053Z","avatar_url":"https://github.com/mafintosh.png","language":"JavaScript","funding_links":["https://github.com/sponsors/mafintosh"],"categories":["JavaScript","Packages","Repository","Uncategorized","包","命令行","目录","others","Debugging / Profiling","Node"],"sub_categories":["Debugging / Profiling","Debugging","Uncategorized","调试 / 分析","redux 扩展","调试/分析","macros","调试"],"readme":"# why-is-node-running\n\nNode.js is running but you don't know why? `why-is-node-running` is here to help you.\n\n## Installation\n\nIf you want to use `why-is-node-running` in your code, you can install it as a local dependency of your project. If you want to use it as a CLI, you can install it globally, or use `npx` to run it without installing it.\n\n### As a local dependency\n\nNode.js 20.11 and above (ECMAScript modules):\n\n```bash\nnpm install --save-dev why-is-node-running\n```\n\nNode.js 8 or higher (CommonJS):\n\n```bash\nnpm install --save-dev why-is-node-running@v2.x\n```\n\n### As a global package\n\n```bash\nnpm install --global why-is-node-running\nwhy-is-node-running /path/to/some/file.js\n```\n\nAlternatively if you do not want to install the package globally, you can run it with [`npx`](https://docs.npmjs.com/cli/commands/npx):\n\n```bash\nnpx why-is-node-running /path/to/some/file.js\n```\n\n## Usage (as a dependency)\n\n```js\nimport whyIsNodeRunning from 'why-is-node-running' // should be your first import\nimport { createServer } from 'node:net'\n\nfunction startServer () {\n  const server = createServer()\n  setInterval(() =\u003e {}, 1000)\n  server.listen(0)\n}\n\nstartServer()\nstartServer()\n\n// logs out active handles that are keeping node running\nsetImmediate(() =\u003e whyIsNodeRunning())\n```\n\nSave the file as `example.js`, then execute:\n\n```bash\nnode ./example.js\n```\n\nHere's the output:\n\n```\nThere are 4 handle(s) keeping the process running\n\n# Timeout\nexample.js:6  - setInterval(() =\u003e {}, 1000)\nexample.js:10 - startServer()\n\n# TCPSERVERWRAP\nexample.js:7  - server.listen(0)\nexample.js:10 - startServer()\n\n# Timeout\nexample.js:6  - setInterval(() =\u003e {}, 1000)\nexample.js:11 - startServer()\n\n# TCPSERVERWRAP\nexample.js:7  - server.listen(0)\nexample.js:11 - startServer()\n```\n\n## Usage (as a CLI)\n\nYou can run `why-is-node-running` as a standalone if you don't want to include it inside your code. Sending `SIGUSR1`/`SIGINFO` signal to the process will produce the log. (`Ctrl + T` on macOS and BSD systems)\n\n```bash\nwhy-is-node-running /path/to/some/file.js\n```\n\n```\nprobing module /path/to/some/file.js\nkill -SIGUSR1 31115 for logging\n```\n\nTo trigger the log:\n\n```\nkill -SIGUSR1 31115\n```\n\n## Usage (with Node.js' `--import` option)\n\nYou can also use Node's [`--import`](https://nodejs.org/api/cli.html#--importmodule) option to preload `why-is-node-running`:\n\n```bash\nnode --import why-is-node-running/include /path/to/some/file.js\n```\n\nThe steps are otherwise the same as the above CLI section\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmafintosh%2Fwhy-is-node-running","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmafintosh%2Fwhy-is-node-running","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmafintosh%2Fwhy-is-node-running/lists"}