You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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)
importwhyIsNodeRunningfrom'why-is-node-running'// should be your first importimport{createServer}from'node:net'functionstartServer(){constserver=createServer()setInterval(()=>{},1000)server.listen(0)}startServer()startServer()// logs out active handles that are keeping node runningsetImmediate(()=>whyIsNodeRunning())
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: