How to hide node cmd windows created by "pm2 start" - node.js

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

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

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!

Related

How do have 1 window instead of multiple windowsss, nodejs

I need to have only 1 window, instead of many. I currently use Visual Studio Code, is there a way to integrate the commands into the terminal of VSC? It's very annoying to have so many processes open with nodejs
Thanks
If you go to this link: How to hide node cmd windows created by "pm2 start"
there is an answer that explains how, but for the sake of it, you just need to add in the 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",
Please +1 if it helps. Thanks :)

How to use Command Prompt after ng serve was compiled

In Angular 5, after creating project folder, installing Angular CLI, Node.js (all latest versions) and ng serve was compiled successfully through command prompt. Then I tried to use command prompt to install bootstrap. I could not control / use command prompt. What might be the cause and effect?
Command prompt stuck after compilation
There are simple ways:
If you use Command Prompt(Terminal), open another Command Prompt inside your project path.
If you use IDE like Visual Studio Code, open Terminal and then you can use Plus(+) sign for openning anothor Terminal like below image:
If you use IDE like WebStrom (Jetbrains IDE), first open IDE Terminal then make right click and select New Session and new terminal openning like below image:
There are couple of ways you can do that.
The official way of deployment of angular app.
Create a start.bat (if you are using windows) and write the ng serve --open command there. Now you can run this file which will internally run your angular app, using forever or pm2 npm modules.
If you do that these will demonise your process to run in background and your same command prompt becomes usable again.
Once the process is finished( compiled successfully), you would notice that the cmd -prompt newline doesn't show any directory and its blank.
This means that, you just have to open an another (new terminal), get to the right directory using "cd command "and implement your desired commands or operations again.
use ctrl + v it will ask weather to terminate say Y, cursor will go back

Launching Node packages.json scripts from Embedded Terminal in WebStorm

In WebStorm 2016.2.2 for Windows 7 Professional x64, I would like to go to Tools->Run Gulp/Grunt/npm Task and be able to launch npm tasks from the embedded terminal.
The reason is I am running a yo generator which requires use of the arrow keys to select multiple-choice option outputs, and the default terminal (Run Windows) that WebStorm launches does not support this, but the Embedded Terminal (Alt+F12) functions exactly as intended. Any help is greatly appreciated!
I ended up prepending 'start' to open up a separate terminal window.
For example: "scripts":{"testCmd" : "start cmd.exe #cmd /k \"echo \"hello there\" && exit 1\""}
This opens the command line natively in Windows, prints "hello there", and closes the command line window.

Equivalent for Linux's "screen"

Is there anything similiar to Linux's "screen"? What I want to do is launch console application created in Java. Then let's say I want to execute command to the running application. For example I want to tell it to exit so I'll tell it command 'exit'. On Linux I can open the application "in screen" and later if I want to tell it any command I can attach the "screen", tell it the command and detach. I don't need screen but I need something that can do this. It would also be cool if I could do it without installing any additional software.
You can install cygwin and within cygwin install screen.

Node.js Command Prompt

I'm trying to learn Node.js. I really like a lot of the ideas I've seen. Currently, I have "Hello, World" working. To run hello world, I simply type node hello.js from a windows command prompt. Now, I'm trying to integrate Node in with Visual Studio as a Tool. Essentially, I want to be able to click the "TOOLS" menu in Visual Studio and choose "Node", and my currently selected file will run in a Node environment.
My question is, how do I do this? Currently, I have the following external tool configured:
Title: &Node
Command: C:\Windows\System32\cmd.exe
Arguments: node $(ItemFileName)
Initial Directory: $(ItemDir)
When I choose "Node" from the "TOOLS" menu, a command prompt window is opened. The directory is set to the directory of the file I've chosen. However, the command "node [filename]" doesn't get executed or entered. What am I doing wrong?
So I replicated the issue you've experienced so I've tried to simply point it to node.exe instead and seems to work pretty well ;)) Will probably end up using this as well!

Resources