How to hide node cmd windows created by "pm2 start"
Asked Answered
P

3

12

enter image description here

One cmd window per node process, I don't know what these windows for. Can I hide them?

Plumbaginaceous answered 14/12, 2016 at 4:21 Comment(2)
Bad luck! its a known issue, see here github.com/Unitech/pm2/issues/2182Pottage
Did you fix it?Aziza
S
0

Using AutoHotkey I solved this problem for me on Windows. This will add a tray icon in the notification area of the taskbar (somewhere next to the clock). You can also stop the script itself and the node.js script by right clicking this icon then "Exit".

#SingleInstance, force

OnExit, ExitSub
RunWait, node "main.js", % A_ScriptDir, Hide, pid
ExitApp

ExitSub:
Process, close, % pid
ExitApp

With %comspec% you can write the output to a file if needed. This would then be something like RunWait, %comspec% /c "node "main.js" > "log.txt""

Swanee answered 22/8, 2018 at 6:17 Comment(0)
H
0

run pm2 with --no-daemon -i 1 (cluster)

like pm2 start index.js --no-daemon -i 1 --name yournameapp

Hevesy answered 20/11, 2023 at 16:15 Comment(0)
A
-2

What you can do is, well... in my case I use Visual Studio Code, you forgot to include your IDE in your question. Now with VSC I have integraded the terminal, so I don't really have 3 windows floating around. Now, there is a work-around with windows, which in mac doesn't happen, in order to have the 3 windows you would have to include in your settings:

//Terminal Configurations

//PowerShell Windows
//"terminal.integrated.shell.windows": "C:\\WINDOWS\\system32\\cmd.exe",

//GIT Bash Configuration
"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe",

so when you clik on the plus, it would create a "new window" but not floating around, look:

enter image description here

Btw, you cannot have both activated at the same time, one for bash, one for cmd, I use cmd for my mongodb, and bash for the rest.

You can also substitute bash or cmd for nodejs command line if you wanted to, just put it in one of the routes above :)

Hope it helps!

Anthropomorphic answered 27/6, 2018 at 20:43 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.