How to hide node cmd windows created by “pm2 start”

杀马特。学长 韩版系。学妹 提交于 2019-12-08 17:26:43

问题


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


回答1:


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:

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!




回答2:


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""



来源:https://stackoverflow.com/questions/41134794/how-to-hide-node-cmd-windows-created-by-pm2-start

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!