why-is-node-running

中文文档
3.2.3发布于 2026/10/09MITTypeScriptES Module零依赖构建来源已验证近 30 天下载 5.2亿

Node is running but you don't know why? why-is-node-running is here to help you.

原始使用文档
文档目录7 节
  1. Installation
  2. As a local dependency
  3. As a global package
  4. Usage (as a dependency)
  5. Usage (as a CLI)
  6. Usage (with Node.js' --import option)
  7. License

why-is-node-running

Node.js is running but you don't know why? why-is-node-running is here to help you.

Installation

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

As a local dependency

Node.js 20.11 and above (ECMAScript modules):

npm install --save-dev why-is-node-running

Node.js 8 or higher (CommonJS):

npm install --save-dev [email protected]

As a global package

npm install --global why-is-node-running
why-is-node-running /path/to/some/file.js

Alternatively if you do not want to install the package globally, you can run it with npx:

npx why-is-node-running /path/to/some/file.js

Usage (as a dependency)

import whyIsNodeRunning from 'why-is-node-running' // should be your first import
import { createServer } from 'node:net'

function startServer () {
  const server = createServer()
  setInterval(() => {}, 1000)
  server.listen(0)
}

startServer()
startServer()

// logs out active handles that are keeping node running
setImmediate(() => whyIsNodeRunning())

Save the file as example.js, then execute:

node ./example.js

Here's the output:

There are 4 handle(s) keeping the process running

# Timeout
example.js:6  - setInterval(() => {}, 1000)
example.js:10 - startServer()

# TCPSERVERWRAP
example.js:7  - server.listen(0)
example.js:10 - startServer()

# Timeout
example.js:6  - setInterval(() => {}, 1000)
example.js:11 - startServer()

# TCPSERVERWRAP
example.js:7  - server.listen(0)
example.js:11 - startServer()

Usage (as a CLI)

You 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)

why-is-node-running /path/to/some/file.js
probing module /path/to/some/file.js
kill -SIGUSR1 31115 for logging

To trigger the log:

kill -SIGUSR1 31115

Usage (with Node.js' --import option)

You can also use Node's --import option to preload why-is-node-running:

node --import why-is-node-running/include /path/to/some/file.js

The steps are otherwise the same as the above CLI section

License

MIT

版本与发布记录

why-is-node-running 共发布 25 个版本,首次发布于 2016/02/09;过去 12 个月发布了 1 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
3.2.3latest2026/10/0929 天前
3.2.22025/01/081.8 年前
3.2.12024/10/302 年前
3.2.02024/07/132 年前
3.1.02024/07/102 年前
3.0.02024/07/082 年前

关于 why-is-node-running 的常见问题

why-is-node-running 是什么?

Node is running but you don't know why? why-is-node-running is here to help you.

如何安装 why-is-node-running?

在项目目录运行 npm install why-is-node-running,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 why-is-node-running,可以用 npx why-is-node-running 直接运行。

why-is-node-running 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

why-is-node-running 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

why-is-node-running 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20.11。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

why-is-node-running 可以商用吗?

why-is-node-running 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

why-is-node-running 的下载量有多少?

根据 npm 官方下载统计,why-is-node-running 在 2026/10/07 – 2026/11/05 这 30 天内被下载 517,340,758 次,日均约 17,244,692 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

why-is-node-running 还在维护吗?

最新版本 3.2.3 发布于 2026/10/09(29 天前);至今共发布 25 个版本,其中过去 12 个月发布了 1 个;首次发布于 2016/02/09。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。