Unitech / Unitech/pm2

Windows 11: Error: spawn wmic ENOENT

Open
#5,311 4 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
43.3k
Forks
2.7k
PR merge metrics
No merged PRs in 30d

Description

What's going wrong?

Error caught while calling pidusage
PM2      | Error: Error: spawn wmic ENOENT
PM2      |     at ChildProcess.<anonymous> (C:\Users\Daniil\AppData\Roaming\npm\node_modules\pm2\node_modules\pidusage\lib\bin.js:33:10)
PM2      |     at ChildProcess.emit (node:events:526:28)
PM2      |     at ChildProcess.emit (node:domain:475:12)
PM2      |     at Process.ChildProcess._handle.onexit (node:internal/child_process:289:12)
PM2      |     at onErrorNT (node:internal/child_process:476:16)
PM2      |     at processTicksAndRejections (node:internal/process/task_queues:83:21)

How could we reproduce this issue?

  1. ecosystem.config.js
module.exports = {
    apps: [{
        name: "tg-steam-2fa",
        script: "./index.js",
        watch: true
    }]
}
  1. pm2 start ecosystem.config.js

Supporting information

This issue has been reported before (#3873, #4954).

I'm running Windows 11 (build 22557.ni_release.220210-1445), and it appears that wmic has been deprecated in Windows 11 dev builds.

--- PM2 report ----------------------------------------------------------------
Date                 : Mon Feb 21 2022 17:23:40 GMT+0300 (Moscow Standard Time)
===============================================================================
--- Daemon -------------------------------------------------
pm2d version         : 5.2.0
node version         : 17.5.0
node path            : not found
argv                 : C:\Program Files\nodejs\node.exe,C:\Users\Daniil\AppData\Roaming\npm\node_modules\pm2\lib\Daemon.js
argv0                : node
user                 : undefined
uid                  : N/A
gid                  : N/A
uptime               : 26min
===============================================================================
--- CLI ----------------------------------------------------
local pm2            : 5.2.0
node version         : 17.5.0
node path            : not found
argv                 : C:\Program Files\nodejs\node.exe,C:\Users\Daniil\AppData\Roaming\npm\node_modules\pm2\bin\pm2,report
argv0                : node
user                 : Daniil
===============================================================================
--- System info --------------------------------------------
arch                 : x64
platform             : win32
type                 : Windows_NT
cpus                 : Intel(R) Core(TM) i5-9300H CPU @ 2.40GHz
cpus nb              : 8
freemem              : 1984905216
totalmem             : 8464355328
home                 : C:\Users\Daniil
===============================================================================
--- PM2 list -----------------------------------------------
┌─────┬─────────────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
│ id  │ name            │ namespace   │ version │ mode    │ pid      │ uptime │ ↺    │ status    │ cpu      │ mem      │ user     │ watching │
├─────┼─────────────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
│ 0   │ tg-steam-2fa    │ default     │ 1.0.0   │ fork    │ 10936    │ 24m    │ 0    │ online    │ 0%       │ 0b       │
 Daniil   │ disabled │
└─────┴─────────────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘
===============================================================================
--- Daemon logs --------------------------------------------
C:\Users\Daniil\.pm2\pm2.log last 20 lines:
PM2        | 2022-02-21T17:19:34: PM2 error: Error caught while calling pidusage
PM2        | 2022-02-21T17:19:34: PM2 error: Error: Error: spawn wmic ENOENT
PM2        | 2022-02-21T17:20:04: PM2 error: Error caught while calling pidusage
PM2        | 2022-02-21T17:20:04: PM2 error: Error: Error: spawn wmic ENOENT
PM2        | 2022-02-21T17:20:34: PM2 error: Error caught while calling pidusage
PM2        | 2022-02-21T17:20:34: PM2 error: Error: Error: spawn wmic ENOENT
PM2        | 2022-02-21T17:21:04: PM2 error: Error caught while calling pidusage
PM2        | 2022-02-21T17:21:04: PM2 error: Error: Error: spawn wmic ENOENT
PM2        | 2022-02-21T17:21:34: PM2 error: Error caught while calling pidusage
PM2        | 2022-02-21T17:21:34: PM2 error: Error: Error: spawn wmic ENOENT
PM2        | 2022-02-21T17:22:04: PM2 error: Error caught while calling pidusage
PM2        | 2022-02-21T17:22:04: PM2 error: Error: Error: spawn wmic ENOENT
PM2        | 2022-02-21T17:22:34: PM2 error: Error caught while calling pidusage
PM2        | 2022-02-21T17:22:34: PM2 error: Error: Error: spawn wmic ENOENT
PM2        | 2022-02-21T17:23:04: PM2 error: Error caught while calling pidusage
PM2        | 2022-02-21T17:23:04: PM2 error: Error: Error: spawn wmic ENOENT
PM2        | 2022-02-21T17:23:34: PM2 error: Error caught while calling pidusage
PM2        | 2022-02-21T17:23:34: PM2 error: Error: Error: spawn wmic ENOENT
PM2        | 2022-02-21T17:23:40: PM2 error: Error caught while calling pidusage
PM2        | 2022-02-21T17:23:40: PM2 error: Error: Error: spawn wmic ENOENT

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce with ecosystem.config.js and pm2 start ecosystem.config.js on the reported Windows 11 environment, then inspect the pidusage/lib/bin.js entry shown in the stack trace. Trace how the missing wmic executable is used for process metrics; done means PM2 no longer repeatedly logs spawn wmic ENOENT on systems where WMIC is unavailable.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
backend, cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.