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

NPM as spawned child process does not work #81

Open
Choppel opened this issue Apr 26, 2023 · 1 comment
Open

NPM as spawned child process does not work #81

Choppel opened this issue Apr 26, 2023 · 1 comment

Comments

@Choppel
Copy link

Choppel commented Apr 26, 2023

Description

Running on Windows Server 2022, Node 14.21.3, Npm 6.14.18

This is more a question regarding the necessity of running pm2 as "Local Service" rather than a bug report.

An app spawned by pm2 runs properly. Pm2 says it runs as Administrator and everything works as expected. But then this app spawns npm via NodeJS child_process, npm does not work properly. The output is seen below. The culprit seems to be the fact that pm2 is started as "Local Service". When I change it to "Administrator" npm is spawned correctly by the app.
Maybe, on Windows, a child_process is spawned by the user that pm2 runs as and not the user my app runs as. On Linux this is not a problem.

Steps to Reproduce

  1. Install pm2 via pm2-installer as stated in the documentation.
  2. Create a js file or an app that spawns npm and start it via pm2
  3. The app will output something like "Error: EEXIST: file already exists, mkdir 'C:\Users\Administrator\AppData\Roaming\npm'"

If it helps I could provide a precise example.

Environment

Running on: 26.4.2023, pm2-installer 3.4.3 with node v14.21.3 and npm 6.14.18 on win32-10.0.20348.

@mbravo1
Copy link

mbravo1 commented Feb 16, 2024

Hello.

I have the same problem.

I have an app in Nodejs that running with pm2 sends the error 'Access is denied'. How can I make PM2 run as administrator privileges. Or do they have a good execution practice?

Please support me, I have been struggling with this for several days and the only way to solve it was to not use PM2 and create a Windows Task Scheduler.

@Choppel Did you find any solution?

var child = require('child_process').exec('net start MYSERVICE', function (error, stdout, stderr) { if (error !== null){ console.log(error); } else{ console.log("No error"); } });

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

No branches or pull requests

2 participants