0

I have a global npm package that I want to spawn as a process from a NodeJS application.

The problem is that on Windows 10 I have to use the property shell: true, otherwise I will receive the following error as mentioned here

Error: spawn pm2 ENOENT

The problem is that I don't want to show a new shell on the UI when the command is executed, but rather to be a silent detached process.

enter image description here

My code is the following:

 const child: child_process.ChildProcessWithoutNullStreams = child_process.spawn(
    command,
    args,
    {
      shell: true,
      detached: true,
    },
  );
  child.unref();

Mention

I'm using node v14.15.1 on a Windows 10 machine.

I know that there is a property windowsHide, but this one is true by default and is still not working. The shell is still visible.

What should I do to spawn this detached process without showing a new shell on the os UI?

Georgian Stan
  • 1,865
  • 3
  • 13
  • 27
  • Why not solve the core issue instead of finding a workaround for a workaround. Requesting a console and then trying to hide the console doesn't sound like a solution to any problem. – IInspectable Jan 02 '21 at 17:16
  • Hi @IInspectable. Please read the question and the other question that is linked in the post. Without using the property shell:true is not working. – Georgian Stan Jan 02 '21 at 18:21
  • You will need a full path directly to the executable you are trying to run in order to run it without a shell. Finding the executable via the path is something the shell does for you. – jfriend00 Jan 02 '21 at 20:32

0 Answers0