pm2 icon indicating copy to clipboard operation
pm2 copied to clipboard

How to get rid of annoying popups in Windows 10?

Open nakamorichi opened this issue 9 years ago • 167 comments

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

nakamorichi avatar May 21 '16 04:05 nakamorichi

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

  • https://github.com/Unitech/pm2/blob/development/lib/God/ClusterMode.js#L52
  • https://github.com/Unitech/pm2/blob/development/lib/God/ForkMode.js#L94

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

Unitech avatar Jul 04 '16 09:07 Unitech

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

soyuka avatar Jul 04 '16 09:07 soyuka

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

Unitech avatar Jul 04 '16 09:07 Unitech

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 avatar Jul 05 '16 20:07 vmarchaud

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.

vmarchaud avatar Jul 13 '16 14:07 vmarchaud

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

soyuka avatar Jul 13 '16 15:07 soyuka

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

vmarchaud avatar Jul 13 '16 15:07 vmarchaud

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?

soyuka avatar Jul 13 '16 15:07 soyuka

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.

vmarchaud avatar Jul 13 '16 19:07 vmarchaud

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.

ajithr avatar Sep 21 '16 09:09 ajithr

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

vmarchaud avatar Sep 21 '16 10:09 vmarchaud

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.

gustavohenke avatar Sep 21 '16 18:09 gustavohenke

@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()

ghost avatar Oct 28 '16 10:10 ghost

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

vmarchaud avatar Oct 28 '16 11:10 vmarchaud

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

soyuka avatar Oct 28 '16 12:10 soyuka

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 avatar Mar 10 '17 17:03 mswaminath

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.

tayler-king avatar Mar 30 '17 19:03 tayler-king

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!

raghavmac avatar Mar 31 '17 12:03 raghavmac

I use the process json file to launch my pm2 instances so I do not believe that will work for me. On Fri, 31 Mar 2017 at 1:07 pm, Raghav Manikandan [email protected] wrote:

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
  4. Again npm start (this time it stops popping up)

Hope it works!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Unitech/pm2/issues/2182#issuecomment-290694966, or mute the thread https://github.com/notifications/unsubscribe-auth/AQFo-gSTsM1ff6b76yV4Qj20hfUV-uF4ks5rrOyHgaJpZM4Ijsqx .

tayler-king avatar Mar 31 '17 12:03 tayler-king

Any fix to this? Just asking 😄

sant123 avatar May 07 '17 16:05 sant123

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?

ghost avatar May 08 '17 07:05 ghost

Any permanent solution for this ??

parthvakharia avatar Jun 18 '17 04:06 parthvakharia

This issue is especially terrible if you have autorestart enabled, and something causes your script to crash after it loads (I accidentally renamed a file the script frequently reads from). Then all hell breaks loose! Windows are spawning and crashing so fast, I couldn't type or click on anything since the windows spawn in the foreground with focus. It's completely ignoring "max_restarts" and "restart_delay" (i'm guessing these don't apply to clusters). I literally had no choice but to hard reset my computer.

jgjake2 avatar Jul 10 '17 11:07 jgjake2

Wow it feels like I just won a game of solitaire

wayofthefuture avatar Aug 03 '17 18:08 wayofthefuture

So for production applications it is imperative to take the weight off the single event loop by forking a few processes to balance the load. Well, fork() does not take a detached option, and nor should it. Once the primary process fails the child processes will be closed subsequently, allowing pm2 to respawn the parent which will re-fork children, while keeping only 1 instance of each process and maintaining the IPC pipe between them. This is quite simple and the forking nature of the node parent process is beautiful in this regard in my opinion.

At this point our only option is to use pm2 to create 4 actual and separate node apps. This may work, maybe. I have no idea how we will accomplish any kind of IPC messages back and forth from the processes considering there is no parent process to route the messages.

In other words, pm2 for production purposes on windows is currently not working. I will mention that if anyone can find time to resolve this issue, we will be happy to finance your hourly work in the name of getting this problem solved ASAP.

Thank you.

wayofthefuture avatar Aug 05 '17 00:08 wayofthefuture

I have found a very simple fix that am using now for development,

  1. On your pm2 config file, just remove/comment the instances: 1 line
  2. pm2 delete <project-name> (one time process)
  3. npm start

Then you will see the magic, but I suggest to use this only for development.

raghavmac avatar Aug 05 '17 03:08 raghavmac

We aren't using a config file. Our master process forks into sub-processes. Will this work for that?

wayofthefuture avatar Aug 08 '17 09:08 wayofthefuture

SOLVED.

Use winsw and run "node myapp.js" as a windows service.

https://github.com/kohsuke/winsw

wayofthefuture avatar Aug 14 '17 05:08 wayofthefuture

Any updates on this? I run multiple instances so cannot write off instance support.

tayler-king avatar Aug 14 '17 16:08 tayler-king

I've opened this ticket with nodejs: https://github.com/nodejs/node/issues/15217

Would be great if everyone watching this ticket went and upvoted and shared this one. Really it seems like something that wouldn't be high impact for them to fix!

atrauzzi avatar Sep 06 '17 15:09 atrauzzi

I think this is occurring for me on exec processes called by PM2 process management. I am using fork mode. What do you think, does this occur for subprocesses started with exec even with fork?

gregorskii avatar Oct 03 '17 04:10 gregorskii

Any updates? child_process.spawn::windowsHide option is already awailable: https://github.com/nodejs/node/issues/15217#ref-pullrequest-267864790

milichev avatar Nov 02 '17 16:11 milichev

https://github.com/Unitech/pm2/pull/3255 https://github.com/nodejs/node/issues/15217#ref-pullrequest-267864790 thanks to @soyuka @milichev @cjihrig

Unitech avatar Nov 03 '17 16:11 Unitech

May you try development branch @milichev ?

soyuka avatar Nov 03 '17 16:11 soyuka

Is it possible to get this a little earlier than release?

FireController1847 avatar Nov 04 '17 04:11 FireController1847

Installed with no success. The same console fireworks on each watched file change -(

node -v
v8.9.0

yarn global add https://github.com/Unitech/pm2@development

milichev avatar Nov 06 '17 17:11 milichev

Any update?

toddwong avatar Nov 28 '17 01:11 toddwong

It was fixed for me

FireController1847 avatar Nov 28 '17 02:11 FireController1847

@FireController1847 Not for me I think.

git clone [email protected]:Unitech/pm2.git
cd pm2
git checkout development
npm link
cd \test
pm2 start test.js -i 2

Still got 2 black console windows poped up!

node --version v9.2.0 pm2 --version 2.8.0

I'm on Window 10.

Is there any wrong with my setup?

toddwong avatar Nov 28 '17 02:11 toddwong

Ah, actually, you're right. The window does popup. Nevermind.

FireController1847 avatar Nov 28 '17 02:11 FireController1847

Unless i missed something, God.nodeApp(in lib/God/ClusterMode.js) called cluster.fork, which has no windowsHide parameter at all!? Dead end!

toddwong avatar Nov 28 '17 05:11 toddwong

I got a hacky solution

diff --git a/lib/God.js b/lib/God.js
index bf3bedda..61178584 100644
--- a/lib/God.js
+++ b/lib/God.js
@@ -15,7 +15,7 @@
  ******************************/

 var semver        = require('semver');
-var cluster       = require('cluster');
+var cluster       = require('./cluster_hack');
 var numCPUs       = require('os').cpus() ? require('os').cpus().length : 1;
 var path          = require('path');
 var EventEmitter2 = require('eventemitter2').EventEmitter2;
diff --git a/lib/God/ClusterMode.js b/lib/God/ClusterMode.js
index 3a1185a3..af9bf43a 100644
--- a/lib/God/ClusterMode.js
+++ b/lib/God/ClusterMode.js
@@ -10,7 +10,7 @@
  * @author Alexandre Strzelewicz <[email protected]>
  * @project PM2
  */
-var cluster       = require('cluster');
+var cluster       = require('../cluster_hack');
 var cst           = require('../../constants.js');
 var Utility       = require('../Utility.js');
 var pkg           = require('../../package.json');
@@ -49,7 +49,7 @@ module.exports = function ClusterMode(God) {
       // { "args": ["foo", "bar"], "env": { "foo1": "bar1" }} will be parsed to
       // { "args": "foo, bar", "env": "[object Object]"}
       // So we passing a stringified JSON here.
-      clu = cluster.fork({pm2_env: JSON.stringify(env_copy), windowsHide: true});
+      clu = cluster.fork({pm2_env: JSON.stringify(env_copy), pm2_windowsHide: true});
     } catch(e) {
       God.logAndGenerateError(e);
       return cb(e);
diff --git a/lib/cluster_hack.js b/lib/cluster_hack.js
new file mode 100644
index 00000000..c1cfd86b
--- /dev/null
+++ b/lib/cluster_hack.js
@@ -0,0 +1,18 @@
+var child_process = require('child_process');
+var oldFork = child_process.fork;
+child_process.fork = function () {
+  var pos = 1;
+  if (pos < arguments.length && Array.isArray(arguments[pos]))
+    pos++;
+  if (pos < arguments.length && arguments[pos] != null
+          && typeof arguments[pos] === 'object'
+          && arguments[pos].env && arguments[pos].env.pm2_windowsHide) {
+    arguments[pos].windowsHide = true;
+    arguments[pos].silent = true;
+  }
+  return oldFork.apply(this, arguments);
+};
+var cluster = require('cluster');
+child_process.fork = oldFork;
+
+module.exports = cluster;

But still get black windows flashing when pm2 stop x pm2 kill pm2 update ...


edit: I make a fork, toddwong/pm2@dc184e9ef76badbb565d9d61f6d39d4dda712db5

toddwong avatar Nov 28 '17 15:11 toddwong

This should be fixed in nodejs then no?

soyuka avatar Nov 28 '17 15:11 soyuka

@soyuka Not sure, but I've filed a feature request nodejs/node#17370 But the black windows during pm2 stop x etc. should be address in pm2 I think.

toddwong avatar Nov 28 '17 15:11 toddwong

When using fork with watch activated, a black window flashes everytime a change is detected. Is this normal behavior?

TheOptimisticFactory avatar Dec 11 '17 12:12 TheOptimisticFactory

It seems is almost done https://github.com/nodejs/node/pull/17412

sant123 avatar Jan 04 '18 19:01 sant123

Meanwhile, if this helps someone: [email protected] is the last version that doesn't show pop-ups for me on win7, fork mode (above that, it doesn't matter if I run fork mode or cluster, it always shows popups).

dwelle avatar Jan 18 '18 13:01 dwelle

Should work now, please try latest pm2 published:

$ npm install pm2 -g
$ pm2 update

Unitech avatar Jan 22 '18 17:01 Unitech

Unfortunately continues spawning these windows 😞

image

Node: v9.4.0 OS: Windows 10 pm2: v2.9.2

Command: pm2 start app.js -i max terminal: tested in git-bash, cmd and powershell

sant123 avatar Jan 23 '18 01:01 sant123

The server script:

const http = require("http");
const server = http.createServer(handler);
const port = 4875;

server.listen(port, () => {
    console.log("Listening at port %d", port);
});

function handler(req, res) {
    res.end("Holita desde Node.js");
}

sant123 avatar Jan 23 '18 01:01 sant123

Still issues on [email protected] win7, config:

"exec_mode": "fork_mode",
"instances": 1

dwelle avatar Jan 23 '18 08:01 dwelle

Issue persists on windows 10 (pm2 version 2.9.3, node 9.4)

The prompts are only vissible for half a second though. Less than the 4 seconds of previous versions.

metrotyranno avatar Jan 24 '18 01:01 metrotyranno

PM2 3.0.0 has been released:

$ npm install pm2@latest -g
$ pm2 update

Be aware of breaking changes, especially drop support for node 0.12. Full list here : https://github.com/Unitech/pm2/blob/master/CHANGELOG.md

wallet77 avatar Jul 04 '18 12:07 wallet77

And why was this issue closed? After updating to pm2 3.0.0, I still have the same issue...

newlukai avatar Jul 05 '18 06:07 newlukai

It was closed cause we merged a PR which try to fix this issue. We were waiting for feedback about it.

wallet77 avatar Jul 05 '18 08:07 wallet77

And why was this issue closed? After updating to pm2 3.0.0, I still have the same issue...

Mhh did you update pm2 in memory? the windowsHide feature added in nodejs should fix this.

soyuka avatar Jul 05 '18 09:07 soyuka

I updated to 3.0 by running npm install pm2 -g and then pm2 update . Window is still popping up for me.

rastographics avatar Jul 09 '18 13:07 rastographics

Should we be using a specific node version to fix this? I see that 8.8 added the windowsHide feature and I'm using 8.11.2.

Also tried on latest Node 10.6.0 and window still appears

rastographics avatar Jul 09 '18 13:07 rastographics

Still experiencing windows popping up with 3.0.3. After starting a bunch of node services via pm2 start <configFile>, once in a while a cmd window pops up. Before I can get an idea what it displays, it's closed again. It seems this happens in a quite regular interval (every ~30 seconds). UPDATE: I made a screencast in order to see this window popping up before it's closed again. At least, I can tell you that it's the Windows Management Instrumentation Command (wmic.exe) regularly being executed. Unfortunately, there is no information in the shell window which command might be run.

newlukai avatar Aug 06 '18 13:08 newlukai

Hey guys, After playing with this error for a little while, I fixed it by using the NODE.JS Child_Process Documentation.

https://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback

In my app the first file to be read is the index.js on the root of the app.

In the Documentation the lines look like this: const { spawn } = require('child_process');

const subprocess = spawn(process.argv[0], ['child_program.js'], { detached: true, stdio: 'ignore' });

subprocess.unref();

But,

I added the follow lines in my index.js file:

const { spawn } = require('child_process');

const subprocess = spawn(process.argv[0], ['index.js'], { stdio: 'ignore', windowsHide: true });

subprocess.unref();

Notice I remove the detached and add the windowsHide. And it works like charm! Good luck! Cleber

cleberar38 avatar Aug 20 '18 11:08 cleberar38

It was closed cause we merged a PR which try to fix this issue. We were waiting for feedback about it.

Shouldn't we document that when using a child process, the developper should use the windowsHide option?

soyuka avatar Aug 20 '18 11:08 soyuka

Shouldn't we document that when using a child process, the developper should use the windowsHide option?

Problem is : we will copy/paste nodejs documentation. This work is not really ours but it's developer's responsibility. Anyway we can add a little explanation.

But I'm not sure everyone who has this issue is because of child process.

wallet77 avatar Aug 20 '18 15:08 wallet77

Sorry guys, after a little while I notice that node was consuming so much memory after I did the adjustment I mention above. Well, I came into another solution: Here we go:

package.json { "scripts": { "build": "webpack --config prod.config.js && pm2 start server.js" }, "proxy": "//example.com:3000" } This will allow the static files to be served in the same port without conflict! But you can run it in a different port but there is more to be done!

server.js

const express = require('express') const app = express()

app.get('/', (req, res) => res.send('Hello World!'))

app.listen(3000, () => console.log('Example app listening on port 3000!'))

Well, I did notice any memory leak but I will keep my eyes open and I will double check later. I hope it leads to a good solution for you guys!

cleberar38 avatar Aug 29 '18 18:08 cleberar38

With 3.1.2 it got even worse. Every 10 or 20 seconds, for each started app a window is (really fast) opened and closed. With 10 started apps, it's not really that usable.

newlukai avatar Sep 17 '18 11:09 newlukai

Are there any workarounds for this ? I've tried using @cleberar38 's implementation but it still spawns popups.

inkhsutesou avatar Sep 20 '18 17:09 inkhsutesou

Same here with version 3.1.3. Cmd windows every 10 seconds. It leaves the computer unusable for any purpose other than serving.

biels avatar Sep 24 '18 18:09 biels

Only node >= 9.4.0 supports windowsHide in cluster.settings. So this only works for node >= 9.4.0 with pm2 cluster mode. And you have to take care of you own child processes as well.

toddwong avatar Sep 25 '18 01:09 toddwong

any solution ? cmd windows opened and closed.

liangwenzhong avatar Sep 27 '18 06:09 liangwenzhong

@toddwong

Hey, I apologize for asking for your time but would you be willing to write up instructions here on how to change this.

I am able to set PM2 to cluster, but I do not see where to place " windowsHide " What does it mean to take care of your own child processes ?

Any answers are appreciated but there are enough users here that need a work around that it would help greatly to have this explained

Thank you !

inkhsutesou avatar Sep 27 '18 13:09 inkhsutesou

PM2 3.0.0 has been released:

$ npm install pm2@latest -g
$ pm2 update

Be aware of breaking changes, especially drop support for node 0.12. Full list here : https://github.com/Unitech/pm2/blob/master/CHANGELOG.md

Fixed my issue. in Windows 10

MahbbRah avatar Sep 30 '18 16:09 MahbbRah

@inkhsutesou I mean if you call child_process.fork/exec/... in your own scripts, you'd have to set the windowsHide flag to true in the parameters. if you call cluster.fork in your own scripts, and you are working with node >= 9.4.0, you'd have to set the windowsHide flag to true when you call cluster.setupMaster. if you are working with node < 9.4.0, there isn't that windowsHide flag at all, and the black window may unavoidable.

toddwong avatar Oct 02 '18 12:10 toddwong

I am running standard, out of the box configuration on Windows 8 and Node 10.11. What do I need to do to make the console flashing stop?

PM2 version 3.1.3.

gk0r avatar Oct 02 '18 14:10 gk0r

8.x is the current LTS branch. Was this fix merged into any specific 8.x release, or do we need to wait for 10.x LTS?

atuttle avatar Oct 02 '18 19:10 atuttle

Latest version without this behavior for me is 3.0.3, every version to latest (3.2.2) - still occure.

duchu-net avatar Oct 05 '18 16:10 duchu-net

I can confirm what @duchu-net indicated in his comment


Edited for clarity: Running in the following environment

  • Node v10.11.0
  • Npm v6.4.1
  • Yarn v1.9.4

TheOptimisticFactory avatar Oct 08 '18 09:10 TheOptimisticFactory

@JoeTheFkingFrypan which version of Node?

atuttle avatar Oct 08 '18 17:10 atuttle

@atuttle I am using the following

  • Node v10.11.0
  • Npm v6.4.1
  • Yarn v1.9.4

TheOptimisticFactory avatar Oct 09 '18 06:10 TheOptimisticFactory

Fair enough. Doesn't help those of us that would prefer to stay on Node LTS 8.x until 10.x becomes LTS though.

atuttle avatar Oct 15 '18 18:10 atuttle

Guys I dont know how but after reinstaling PM2 i dont see this problem anymore. I also had problem with popups when launching gekko bot with pm2.

I cant say what i did, - Im only start study Node.js and else. To understand more how npm work i was delete pm2, install it local and global couple times. I was also deleted some catalogs and files in my user directory and in catalogs in AppData directory.

Sorry for this useless post I just want to say that solution exist. And maybe some one with more experience will find the answer.

pm2 3.2.2 Windows 10 node v8.11.3 npm 5.6.0

After few hours I just installed pm2 for the first time on my second PC, I don’t see this problem at all.

ExOmRa avatar Oct 21 '18 10:10 ExOmRa

Experienced this with a node and pm2 installation done today. Everything is the latest. Still too many annoying pop ups.

majimboo avatar Oct 22 '18 17:10 majimboo

I am also experiencing this issue.

Node : v8.11.1 Pm2 : 3.2.2 OS : Windows 10 NPM : 5.6.0

yeikel avatar Nov 02 '18 19:11 yeikel

I can confirm what @duchu-net indicated in his comment

Edited for clarity: Running in the following environment

  • Node v10.11.0
  • Npm v6.4.1
  • Yarn v1.9.4

it really works! thanks!

jakejakeho avatar Nov 05 '18 12:11 jakejakeho

I was experiencing this issue, and I solved with a json configuration to run my apps (I suggest to use this only in development mode)

{
  "apps": [
    {
      "name": "apigateway",
      "script": "./../apigateway/ApiGateway.js",
      "exec_mode": "fork",
      "env": {
		  "NODE_ENV":"development"
	  }
    },
    {
      "name": "mainSrv",
      "script": "./../main-srv/ExpressServer.js",
      "exec_mode": "fork",
      "env": {
		  "NODE_ENV":"development"
	  }
    }
  ]
}

Hope it helps!

matteoPhre avatar Nov 15 '18 15:11 matteoPhre

I also get this issue. Thanks for peoples suggestions above to resolve it, but none of them worked for me. I used an ecosystem.config.js and saw identical behaviour to running the app without it.

Node: 10.10.0 PM2: 3.03, 3.2.2 (note: running in fork mode) O/S: Windows 10 NPM: 6.4.1

@toddwong @cleberar38 The windowsHide flag that was mentioned - how would I use that in my setup please? I am using pm2 to run a script from package.json currently. Can I still somehow edit the index.js to add that flag?

package.json

...
"scripts": {
    "build": "rimraf dist && babel src -d dist",
    "test:e2e": "dotenv -e envs/test.env -e envs/.env ./scripts/e2e.test.sh",
    "serve": "yarn run build && node dist/index.js"
  }
...

e2e.test.sh

#!/usr/bin/env bash
...
if ! netstat -aon | grep "0.0.0.0:$SERVER_PORT" | grep "LISTENING"; then
  pm2 -s start ./scripts/serve.js
  until netstat -aon | grep "0.0.0.0:$SERVER_PORT" | grep "LISTENING"; do
    sleep $RETRY_INTERVAL
  done
...
pm2 delete all

serve.js (had to use this as a workaround for another issue I had using pm2 in my environment)

var cmd = require('node-cmd');
cmd.run('npm run serve');

If anyone has other suggestions or thinks they can fix, I will happily test them out :)

msm1089 avatar Nov 19 '18 08:11 msm1089

@msm1089 try this:

var exec = require('child_process').exec;
exec('npm run serve', {windowsHide: true});

toddwong avatar Nov 23 '18 15:11 toddwong

@toddwong Perfecto! I briefly see a couple of cmd windows open, but they go away and stay away :)

msm1089 avatar Nov 27 '18 03:11 msm1089

thanks for figuring out this, I'm using node app with pm2 on windows server 2016 and both exec and spawn call are now not flashing any cmd popups. ( they are staying hidden )

pm2 version : 3.2.2 node 10.14.1

navinmistry avatar Dec 11 '18 13:12 navinmistry

As @TheOptimisticFactory suggested, downgrading pm2 to 3.0.3 does the job for Node 8.x users.

Thank you !

BenjaminDish avatar Dec 21 '18 10:12 BenjaminDish

reverting to PM2 3.0.3 indeed fixes this problem. Still worth a bump I think.

dekdevy avatar Jan 11 '19 12:01 dekdevy

Just tried the current version 3.3.1 and there it's getting worse. Pm2 doesn't stop to open and instantly close pop ups. It was quite difficult to enter "pm2 stop all".

newlukai avatar Feb 25 '19 08:02 newlukai

Still annoyed by this issue..

ColinTree avatar Mar 07 '19 08:03 ColinTree

Last version where this not appears is "pm2": "3.0.3". That means, it was fixed and after 3.0.3 it is back again.

So I can't upgrade to 3.4.0. It is not possible to develop when the window pops up and closes on any change.

florian-kittel avatar Mar 17 '19 10:03 florian-kittel

same issue. v3.4.0 popup 4 window every second and disappear quickly too

snowwolfjay avatar Mar 23 '19 06:03 snowwolfjay

v3.0.3 does not work for me. But v2.10.4 (with node 6.4 ) does not pop at all.

clarkttfu avatar Mar 26 '19 09:03 clarkttfu

If anyone have a clue of which option should be passed to spawn function to avoid this behavior that is welcome.

Here is the culprit: https://github.com/Unitech/pm2/blob/master/lib/God/ForkMode.js#L98

Unitech avatar Apr 05 '19 14:04 Unitech

child_process - windowsHide not working with detached: true It seems a bug of node. Maybe you should change a way to start Daemon @Unitech. I use a detached process to start Daemon.js.Then run pm2 start, it do well.

lllnnnggg555 avatar Apr 11 '19 12:04 lllnnnggg555

If you use npx pm2 kill and npx pm2 start --no-daemon to start the dev server, editing node_modules/pm2/lib/God/ForkMode.js:93 and changing detached : false, to detached : true, it doesn't create annoying popups.

System: node -v v11.14.0 npm -v 6.7.0 pm2: "^3.5.0", windows 10

zveljkovic avatar May 23 '19 23:05 zveljkovic

Same issue. I've tried different node versions and different pm2 versions, it still doesn't work.

Node: 8.2.1, 10.12.0, 10.14.1, 10.16.0 PM2: 3.0.3, 3.5.1 Windows 10

If I run some simple code like this blow, it won't popup windows.

pm2 start test.js
setInterval(() => {
	console.log('test...');
}, 50);

In the opposite way that running a big system would cause so many popups and super fast. Only I can do is rebooting.

Cheney925 avatar Jun 13 '19 09:06 Cheney925

As a workaround you can use pm2 on a linux subsystem. It works pretty well.

ekantor avatar Jul 18 '19 19:07 ekantor

Any updates? I want develope node apps on windows

htchtc052 avatar Jul 20 '19 10:07 htchtc052