Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get rid of annoying popups in Windows 10? #2182

Open
nakamorichi opened this issue May 21, 2016 · 164 comments
Open

How to get rid of annoying popups in Windows 10? #2182

nakamorichi opened this issue May 21, 2016 · 164 comments

Comments

@nakamorichi
Copy link

How do I disable the popup windows that pm2 generates in Windows 10 when starting, restarting or reloading a Node.js app? From the perspective of rapid server-side development, this is very annoying...

@Unitech
Copy link
Owner

Unitech commented Jul 4, 2016

Would it be an issue because of the way we spawn processes?

I don't know if I have to customize something on this code segments,

@soyuka
Copy link
Collaborator

soyuka commented Jul 4, 2016

{detached: true should get rid of this error but it is not available for cluster.

@Unitech
Copy link
Owner

Unitech commented Jul 4, 2016

interesting, maybe @ThisIsMac47 will have a look at this on the next weeks

@vmarchaud
Copy link
Contributor

vmarchaud commented Jul 5, 2016

After testing, the detached option doesnt hide popups on Windows, i think that nodejs spawn a shell to spawn the process.
I will investigate more in the next days.

@vmarchaud
Copy link
Contributor

Okay so :

  • In fork mode, you shouldnt have popups in the dev branch since now
  • In cluster mode, unfortunately, we dont have control on the popup cause we use the cluster implementation of nodejs.

If you get any popup apart of cluster mode, respond to this issue to report it, i will investigate for each one.

@soyuka
Copy link
Collaborator

soyuka commented Jul 13, 2016

Because we can't get detached: true in cluster?

@vmarchaud
Copy link
Contributor

They use the function fork, we can use detached: true only with spawn.

@soyuka
Copy link
Collaborator

soyuka commented Jul 13, 2016

Yes ok so if that's the main reason, the only solution is to port cluster into pm2 instead of using the nodejs cluster.
Did you try a simple cluster implementation without pm2 to see if it pops up too?

@vmarchaud
Copy link
Contributor

I wasnt able to reproduce with a simple cluster implementation, this might coming from the fact that we are a spawning a child from a forked child or something like this.
We manage to delete the popups in cluster mod by rewriting the implementation on the branch of a forked cluster implementation, we will talk about how include this into future release of pm2.

@ajithr
Copy link

ajithr commented Sep 21, 2016

Is this issue fixed or any workaround available? I have faced the same issue when using cluster mode with watch option. The node window opens multiple time when saving the file.

@vmarchaud
Copy link
Contributor

@ajithr No, like i said, the problem come from nodeJs implementation of the cluster mode. I suggest you to develop in fork mode.

@gustavohenke
Copy link

For me what has been working quite well is to use --no-daemon.
However, if pm2 was previously started as a daemon process, then this flag has no effect and the popups keep appearing, unless I run pm2 kill.

@ghost
Copy link

ghost commented Oct 28, 2016

@gustavohenke I followed your instructions, but it did not work for me. I am using pm2 2.0.19 on Windows 8.1 and I still get a popup window everytime I use child_process.exec()

@vmarchaud
Copy link
Contributor

@centigrade-thomas-becker The fact a popup is spawning when you call child_process.exec isn't coming from pm2, it come from the system of spawning a child process of node itself, you may add detached: true to the spawning config and it will not spawn any popup.

The problem of #2182 is that in cluster mode, we can't control how the process are spawn, so we can't add this options to hide the popup under windows.

@soyuka
Copy link
Collaborator

soyuka commented Oct 28, 2016

@centigrade-thomas-becker you should try to use child_process.spawn and add a {detached: true} option.

@mswaminath
Copy link

mswaminath commented Mar 10, 2017

I wanted to share what I did to overcome the popup.
Initially I will npm start my app that starts pm2 as well, then I will do pm2 stop all immediately. After that when I again do npm start, it just pops up only once and never again.

@tayler-king
Copy link

tayler-king commented Mar 30, 2017

Do we have any updates on this for a proper implementation that will patch this issue?

I use PM2 when locally developing. It's becoming an issue to run pm2 kill after every script run. Consoles interrupting me when working is not welcome.

@raghavmac
Copy link

Try this,

  1. npm start your project as usual (pop-up's keep on coming up)
  2. Stop the project (Ctrl-C)
  3. pm2 delete <project-name>
  4. Again npm start (this time it stops popping up)

Hope it works!

@tayler-king
Copy link

tayler-king commented Mar 31, 2017 via email

@sant123
Copy link

sant123 commented May 7, 2017

Any fix to this? Just asking 😄

@ghost
Copy link

ghost commented May 8, 2017

I wanted to share what I did to overcome the popup.
Initially I will npm start my app that starts pm2 as well, then I will do pm2 stop all immediately. After that when I again do npm start, it just pops up only once and never again.

@mswaminath Can you please post your pm2 config, and how you spawn your child processes?

@parthvakharia
Copy link

Any permanent solution for this ??

@githubUser982
Copy link

githubUser982 commented Feb 9, 2023

I suggest looking at for forever solved this problem, since forever does not not have it.

PS: pm2@4.4 did not help, I have tried detached and not.

@jasonayerp
Copy link

npm i -g pm2@4.4
pm2 update

try it!

Confirmed this resolved the issue for me too.

@githubUser982
Copy link

I'm sorry, forever did indeed have the problem too. My bad. I used node-hide-console-window to work around the problem because v4.4 did not seem to help.

@karikera
Copy link

is this issue abandoned?

@dr3adx
Copy link

dr3adx commented May 14, 2023

piece of shit of a repo when u cant fix simple issue like this that EVERYONE is experiencing

@dr3adx
Copy link

dr3adx commented May 15, 2023

fkin monkey developers

@selimdev00
Copy link

{detached: true should get rid of this error but it is not available for cluster.

Perfect!

@Faf4a
Copy link

Faf4a commented Jul 4, 2023

npm i -g pm2@4.4
pm2 update

try it!

Thanks! This worked just fine for me.. struggled with this issue for multiple months now.

@githubUser982
Copy link

Interesting, I wonder why it works for some.

@Tosinkoa
Copy link

Please any update on this?

@punowo
Copy link

punowo commented Jul 24, 2023

What's the general consensus on how to avoid this issue on Windows ?
No offense but this is troublesome to deal with. I do not understand how Windows can be marked as stable when there's chaotic behaviour like this present in the application.

Node: v18.17.0
pm2: 5.3.0

Again I don't mean to be rude but some of use have no choice when it comes to pm2. There are already large enterprise projects that depend on it I can't just go around ecosystem.config.js files that are hundreds of lines.

We all know Windows has it's problems and that most of the time as a dev you have to work around its shorcomings but after 7 years this issue should have a statement or solution.

@punowo
Copy link

punowo commented Jul 31, 2023

I wrote a program to resolve this issue.

Just use pm2 start noc -- app arg1 arg2 ... to replace pm2 start app -- arg1 arg2 ....

Will all pm2 commands still work ?
Like pm2 delete all and logs ?

@githubUser982
Copy link

There's no consensus. 4.4 works for some, not for others, node-hide-console-window is an option when it doesn't. I haven't tried noc.

I can only conclude that the maintainers don't care for windows, I suppose.

@punowo
Copy link

punowo commented Aug 1, 2023

There's no consensus. 4.4 works for some, not for others, node-hide-console-window is an option when it doesn't. I haven't tried noc.

I can only conclude that the maintainers don't care for windows, I suppose.

Sorry, how do I make use of node-hide-console-window non-programatically, when it comes to pm2 I only have to deal with a ecosystem.js with a lot of envs.

@tooolz
Copy link

tooolz commented Aug 30, 2023

Welp back to nodemon for development I guess

this did it for me.
pm2 seems nice for a production environment, but for developing on windows? forget about it, nodemon to the rescue

@punowo
Copy link

punowo commented Aug 30, 2023

Welp back to nodemon for development I guess

this did it for me. pm2 seems nice for a production environment, but for developing on windows? forget about it, nodemon to the rescue

For what it's worth, I eventually made it work with pm2-installer.
It works on my machine, using the old powershell provided by default by Windows and setting the pm2 service to local service. I also had to deal with how pm2 recognizes npm on Windows by avoiding 'script':'npm' and just passing the npm-cli.js directly to 'script'.

@ve3
Copy link

ve3 commented Sep 27, 2023

I'm using pm2 v 5.3.0

It keep popup powershell window on every socket.io emit the message in node app. (popup and closed but very annoying because I can't focus on other window while it pops up.)

Is this related to this issue?

@hyroqi
Copy link

hyroqi commented Nov 30, 2023

PSA, This window will keep popping up if your app has a crash or problem, I used nodemon to determine what was causing the crash (and the window popup), fixed it and pm2 stopped the unexpected behaviour

@hicodify
Copy link

hicodify commented Jan 17, 2024

I am using version 5.3.0 and I can confirm that the problem continues to occur when running on cluster mode. By any chance do you know if there is a solution for this on Windows?

@ve3
Copy link

ve3 commented Jan 17, 2024

I am using version 5.3.0 and I can confirm that the problem continues to occur when running on cluster mode. By any chance do you know if there is a solution for this on Windows?

I have to moved to use NSSM.

passion0714 added a commit to passion0714/nexrender that referenced this issue Jan 17, 2024
In some instances (like running nexrender-workers with pm2), a command
prompt (`cmd.exe`) window would pop-up every time an external process
was spawned (like `aerender` or `ffmpeg`).

To, workaround this problem (which can be quite annoying), I've added
the `windowsHide` parameter to all the `spawn` calls. This will:

> Hide the subprocess console window that would normally be created on Windows systems

(Source: https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options)

Related: Unitech/pm2#2182
@vite-vit
Copy link

You can run both source and pm2 in git bash. Not in cmd or powershell

@wxfred
Copy link

wxfred commented Apr 1, 2024

A python cmd window always popups in Windows 10 when I do the pm2 start ecosystem.config.js, how to avoid it

// ecosystem.config.js
module.exports = {
  apps: [
    {
      name: 'python',
      script: 'poetry',
      args: ['run', 'python', 'server.py'], // a python flask server
      instances: 1,
      exec_mode: 'fork',
      autorestart: true,
      watch: false,
    },
  ],
};

@DVLP
Copy link

DVLP commented Apr 15, 2024

As @jermitval pointed out the last working version was 4.4
Between versions 4.4 and 4.5 a few dependencies were updated. Looks like the offending one is Vizion

Change Vizion to 0.2.13 and the problem disappears
Run
where node
i.e. C:\Program Files\nodejs\node.exe
open any terminal and go to node_modules\pm2 subfolder i.e. C:\Program Files\nodejs\node_modules\pm2
npm i vizion@0.2.13

Looks like this Vizion package needs a fix because 0.2.13 is an old version with some vulnerabilities. But the popup is so extremely annoying esp focus stealing when editing files with watches on them that for now I'd rather use this old version.

Solution 2 Instead of downgrading vizion you can disable it altogether(whatever it does) and the popups will stop
In process.json

{
  "script": "src/index.js",
  "watch": ["src"],
  "name": "Whatever",
  "vizion": false,
  ...
}

or in command line
pm2 start index.js --no-vizion

@marui-obj
Copy link

marui-obj commented Apr 16, 2024

In my case I have to flush terminal every interval time, so every time it flushes it keep popups annoying terminal at same interval time as it flush, my solutions is just removing that line from my source code.

This is my testcase in Python

# test.py
import time
from os import system, name

def flush():
    if name == "nt":
        _ = system("cls")
    else:
        _ = system("clear")

def main():
    print("foo")
    flush() #Comment me
    time.sleep(1)

if __name__ == "__main__" :
    while(True):
        main()

Is this related?

@matys1
Copy link

matys1 commented Jun 4, 2024

@DVLP setting vizion: false in the config file indeed solved the annoying popups in dev. Though that's really a workaround and not a proper fix. Bizzare that this issue has been open for 6 years.

@abaksha-sc
Copy link

abaksha-sc commented Sep 10, 2024

@matys1 , thank you! Adding vision: false to config file really solved the problem when parameter --no-vizion has no effect. Maybe because for development instance I use command Debug right from VSCode:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests