Open Javihache opened 1 year ago
This is Windows 11. Experienced this same thing on several machines.
Ok, I figured out the problem. It's a permissions problem. For some reason, if I change the Service to use my Windows User to start, then the app starts correctly. Is there a way to fix this?
The error I get is as follows:
2023-08-22T12:09:01: PM2 error: Error: spawn node ENOENT at Process.ChildProcess._handle.onexit (node:internal/child_process:282:19) at onErrorNT (node:internal/child_process:477:16) at processTicksAndRejections (node:internal/process/task_queues:83:21) 2023-08-22T12:09:01: PM2 error: Error caught while calling pidusage 2023-08-22T12:09:01: PM2 error: TypeError: One of the pids provided is invalid 2023-08-22T12:09:07: PM2 error: Error caught while calling pidusage 2023-08-22T12:09:07: PM2 error: TypeError: One of the pids provided is invalid 2023-08-22T12:09:07: PM2 error: Error: spawn node ENOENT at Process.ChildProcess._handle.onexit (node:internal/child_process:282:19) at onErrorNT (node:internal/child_process:477:16) at processTicksAndRejections (node:internal/process/task_queues:83:21) 2023-08-22T12:09:07: PM2 error: Error caught while calling pidusage 2023-08-22T12:09:07: PM2 error: TypeError: One of the pids provided is invalid 2023-08-22T12:09:31: PM2 error: Error caught while calling pidusage 2023-08-22T12:09:31: PM2 error: TypeError: One of the pids provided is invalid 2023-08-22T12:09:31: PM2 error: Error caught while calling pidusage 2023-08-22T12:09:31: PM2 error: TypeError: One of the pids provided is invalid
If I add Local Service as owner of the folder in which my app is installed, I can start the app but it errors directly.
I actually needed to give Local Service Permissions to the containing folder where the app was installed (it was in a folder inside the $HOME folder of the user). That's what solved the issue.
Anyone has any idea how to avoid this problem? Installing outside the home folder maybe?
The problem arises if the application is located in the $HOME folder of a user. Local Service has no permissions by default to access that folder and the application will not start. I am guessing this is some typical "Windows" BS that can't be changed or fixed.
I am using a .ps1 script to install my application on customer's computers, but I cannot forbid them to choose a folder inside their $Home folder. I guess I'll try to add permissions conditionally to the folder in the case that the user installs inside the home folder.
Took me a couple of hours to find this out! Would be good if this information was added as a notice to README!
This problem is not just "Windows BS". I wish it were. Same happens on Mac OS and Debian / Ubuntu etc. In the past, deleting the ~/.pm2 folder altogether helped but I have a case where it makes no difference. This problem has been documented here for years and no fix. At least pm2 could catch this exception and show the service as failed, but no, it shows it as running (green) but PID n/a but 0% cpu and 0b mem...
Description
After installing pm2-installer following the instructions (
npm run configure && npm run setup
), I get an ENOENT error when installing pm2-logrotate (probably unrelated). However when I try to start my application, it shows as a process running on pm2 ls but the memory is 0B and the application doesn't start.I tried removing pm2-installer and re-installing to no avail.
If I remove pm2-installer and install
npm i -g pm2
and then start the app withpm2 start app.js
then the app starts all good.Steps to Reproduce
Environment
Running on: 21/08/2023, pm2-installer 3.4.3 with node v18.17.1 and npm 9.6.7 on win32-10.0.22621.