如何隐藏“pm2 start”创建的节点cmd窗口

时间:2022-10-15 21:59:51

如何隐藏“pm2 start”创建的节点cmd窗口

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

每个节点进程一个cmd窗口,我不知道这些窗口是什么。我可以藏起来吗?

2 个解决方案

#1


0  

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:

你可以做的是,嗯...在我的情况下我使用Visual Studio Code,你忘了在你的问题中包含你的IDE。现在有了VSC,我已经对终端进行了整合,所以我实际上没有3个窗口浮动。现在,有一个解决方案,在mac中不会发生,为了拥有3个窗口,你必须包含在你的设置中:

//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:

所以当你克服加号时,它会创建一个“新窗口”,但不会浮动,看看:

如何隐藏“pm2 start”创建的节点cmd窗口

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.

顺便说一句,你不能同时激活,一个用于bash,一个用于cmd,我使用cmd用于我的mongodb,而bash用于其余部分。

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

如果你愿意,也可以用bash或cmd替换nodejs命令行,只需将它放在上面的一个路由中:)

Hope it helps!

希望能帮助到你!

#2


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

使用AutoHotkey我在Windows上为我解决了这个问题。这将在任务栏的通知区域(时钟旁边的某个位置)添加托盘图标。您也可以通过右键单击此图标然后“退出”来停止脚本本身和node.js脚本。

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

使用%comspec%,您可以根据需要将输出写入文件。这就像RunWait,%comspec%/ c“node”main.js“>”log.txt“”

#1


0  

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:

你可以做的是,嗯...在我的情况下我使用Visual Studio Code,你忘了在你的问题中包含你的IDE。现在有了VSC,我已经对终端进行了整合,所以我实际上没有3个窗口浮动。现在,有一个解决方案,在mac中不会发生,为了拥有3个窗口,你必须包含在你的设置中:

//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:

所以当你克服加号时,它会创建一个“新窗口”,但不会浮动,看看:

如何隐藏“pm2 start”创建的节点cmd窗口

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.

顺便说一句,你不能同时激活,一个用于bash,一个用于cmd,我使用cmd用于我的mongodb,而bash用于其余部分。

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

如果你愿意,也可以用bash或cmd替换nodejs命令行,只需将它放在上面的一个路由中:)

Hope it helps!

希望能帮助到你!

#2


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

使用AutoHotkey我在Windows上为我解决了这个问题。这将在任务栏的通知区域(时钟旁边的某个位置)添加托盘图标。您也可以通过右键单击此图标然后“退出”来停止脚本本身和node.js脚本。

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

使用%comspec%,您可以根据需要将输出写入文件。这就像RunWait,%comspec%/ c“node”main.js“>”log.txt“”