Unitech / Unitech/pm2

[Possible Bug] Ecosystem config refuses to run because it's formatted as an ES Module despite it running fine on another machine

Open
#5,953 2 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

The following ecosystem config refuses to run because it's formatted as an ES Module, but it works fine under my host machine:

export const apps = [
  {
    name: "xivi",
    script: "bun install && bun run build && bun run start",
    interpreter: "none",
    exec_mode: "fork",
    instances: 1,
    autorestart: true,
    watch: false,
    max_memory_restart: "1G",
    env: {
      PATH: `${process.env.HOME}/.bun/bin:${process.env.PATH}`,
    },
  },
];

error on remote machine:

$ pm2 start; pm2 save --force
[PM2][ERROR] File ecosystem.config.js malformated
Error [ERR_REQUIRE_ESM]: require() of ES Module /home/nova/Xivi15/ecosystem.config.js from /home/nova/Xivi15/node_modules/pm2/lib/Common.js not supported.
Instead change the require of ecosystem.config.js in /home/nova/Xivi15/node_modules/pm2/lib/Common.js to a dynamic import() which is available in all CommonJS modules.
    at Common.parseConfig (/home/nova/Xivi15/node_modules/pm2/lib/Common.js:331:12)
    at API._startJson (/home/nova/Xivi15/node_modules/pm2/lib/API.js:934:25)
    at API.start (/home/nova/Xivi15/node_modules/pm2/lib/API.js:329:12)
    at /home/nova/Xivi15/node_modules/pm2/lib/binaries/CLI.js:292:13
    at /home/nova/Xivi15/node_modules/async/internal/withoutIndex.js:8:40 {
  code: 'ERR_REQUIRE_ESM'
}
[PM2] Saving current process list...
[PM2] Successfully saved in /home/nova/.pm2/dump.pm2

on my own machine, heres what happens:

❯ bun run pm2:start
$ pm2 start; pm2 save --force
[PM2] Applying action restartProcessId on app [xivi](ids: [ 0 ])
[PM2] [xivi](0) ✓
┌────┬─────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
│ id │ name    │ namespace   │ version │ mode    │ pid      │ uptime │ ↺    │ status    │ cpu      │ mem      │ user     │ watching │
├────┼─────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
│ 0  │ xivi    │ default     │ N/A     │ fork    │ 361545   │ 0s     │ 1    │ online    │ 0%       │ 5.3mb    │ nova     │ disabled │
└────┴─────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘
[PM2] Saving current process list...
[PM2] Successfully saved in /home/nova/.pm2/dump.pm2

the only difference between my main machine and the remote machine is my main is on arch linux and the remote is debian 12

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 pm2 start with the provided ecosystem.config.js on Arch Linux and Debian 12. Start in node_modules/pm2/lib/Common.js at parseConfig, using the stack trace through API.js and CLI.js to follow configuration loading. Done means the same ES module configuration is handled consistently on both systems, with coverage for the reported failure if the repository has a suitable test location.

Written by the indexing model from the issue text.

Assessment

Tech stack
arch-linux, bun, debian, javascript, linux, node.js
Domain
cli, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.