You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

PM2技术问题:Windows 2008 R2服务器多管理员用户无法执行命令

Fixing PM2 Access Issues for Multiple Admin Users on Windows 2008 R2

Hey there, let's tackle why User 2 can't run PM2 commands even though they're an admin like User 1. This is usually tied to npm global paths, environment variables, or service permissions—here's how to fix it step by step:

1. Verify Global npm Paths & Environment Variables

Windows often installs global npm packages in the current user's profile directory (e.g., C:\Users\User1\AppData\Roaming\npm), which other users can't access by default. Let's check:

  • Have both users run this command in a command prompt:
    npm config get prefix
    
  • If the paths differ (User 1's path is their own profile, User 2's is theirs), you have two options:
    • Option A: Use a shared global path
      1. For both users, set npm to install global packages in a public admin-accessible directory (run as admin):
        npm config set prefix "C:\Program Files\npm"
        
      2. Add this path to the system-wide PATH variable:
        • Right-click "Computer" → "Properties" → "Advanced System Settings" → "Environment Variables"
        • Under "System Variables", edit PATH and add C:\Program Files\npm and C:\Program Files\npm\node_modules
    • Option B: Grant access to User 1's npm directory
      • Navigate to User 1's npm path (e.g., C:\Users\User1\AppData\Roaming\npm), right-click → "Properties" → "Security"
      • Add User 2's account and grant "Full Control" permissions

2. Check PM2 Startup Service Identity

If User 1 set up PM2 to start on boot with pm2 startup, the service is registered under their user account—so User 2 can't manage those processes. Fix this:

  • Have User 2 open an elevated command prompt (right-click → "Run as administrator")
  • First, remove the existing user-specific service:
    pm2 unstartup
    
  • Then register PM2 as a system-wide service (accessible by all admins):
    pm2 startup windows --user SYSTEM
    
  • Save the process list and restart the service:
    pm2 save
    pm2 restart all
    

3. Ensure Elevated Permissions

Even as admins, Windows sometimes restricts access in non-elevated windows:

  • Always have User 2 run command prompts as administrator when using PM2 commands. This avoids permission blocks on system-level resources.

4. Reinstall PM2 to the Shared Path

After setting up the shared global npm path, have User 2 run this in an elevated prompt to ensure PM2 is installed in the accessible directory:

npm install -g pm2

Once you've tried these steps, User 2 should be able to run pm2 list, pm2 start, and other commands just like User 1.

内容的提问来源于stack exchange,提问作者Leonardo Lima

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 09:05:06