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
{{ message }}
Repository navigation
[BUG] npx keeps an idle npm process alive for the whole lifetime of the command it runs #10165
This is not just a request to bump a dependency for a CVE
This is not solely a request to bump a dependency for a CVE
Current Behavior
npx <pkg> (and npm exec -- <pkg>) starts the package's bin as a child process and then stays alive for as long as that child runs.
While the command runs, the process tree looks like this:
npm exec <pkg> <- full Node.js process with npm loaded, only waiting
└─ sh -c '<pkg>' <- shell, only waiting
└─ <pkg> <- the actual program
The npm exec process does no work after the child has started, but it keeps a complete Node.js runtime with npm loaded in memory.
For short commands this does not matter.
It does matter for long-running commands, which is how npx is now used most of the time: MCP servers, language servers, dev servers and watchers are typically configured as npx -y <pkg>.
Each of them is started once per editor window or AI agent session, so a single machine easily ends up with dozens of these idle npm processes at once.
Together they hold a lot of memory that does nothing, and the amount grows with every additional session.
Expected Behavior
Once npm has resolved and installed the package, it should get out of the way instead of waiting as a parent process.
On POSIX systems npm could replace itself with the command via process.execve(), which is available in every Node.js version npm supports.
The program would then keep npm's PID, and no idle npm process would stay behind.
Steps To Reproduce
Run any long-running package bin through npx, for example a stdio MCP server: npx -y <package>.
In a second terminal, inspect the process tree: ps -eo pid,ppid,rss,args --forest.
An npm exec <package> Node.js process stays resident as the grandparent of the program for as long as the program runs.
Start several of them and add up the memory of the npm exec processes.
Activity