would it be possible to compile as windows service executable so it can run on the background without user running manually?
You might not be able to compile to an exe - but it is not hard to use tools such as winsw (https://github.com/kohsuke/winsw) to install them as a service.
Look here: https://github.com/coreybutler/node-windows (or node-linux, or node-osx respectively)
But I didnt try if it works with pkg, only with enclose..
i am using nssm.exe (non sucking service manager) for more then 5 years on 5.000 device :)
it works without any problem.
@serkanp but you ship your js code with it. its not packed inside an exe, right?
You can still ship your exe, but then use your installer to run the nssm command as part of the install (Wix)
@george-kar , nssm makes any console exe run as Service.
So compile Your nodejs with pkg and get exe
Then with nssm, make it service
@serkanp , I have a problem with stopping the service with nssm. Do you change default settings on Shutdown tab? I tried all combinations - nodejs app stops working, but the service never stops
Most helpful comment
@george-kar , nssm makes any console exe run as Service.
So compile Your nodejs with pkg and get exe
Then with nssm, make it service