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

pm2 with pnpm bug #5416

Open
milosworks opened this issue Aug 4, 2022 · 11 comments
Open

pm2 with pnpm bug #5416

milosworks opened this issue Aug 4, 2022 · 11 comments

Comments

@milosworks
Copy link

What's going wrong?

When using pm2 with pnpm an error ocurrs

/home/ubuntu/.local/share/pnpm/pnpm:2
0|pnpm  | basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
0|pnpm  |           ^^^^^^^
0|pnpm  | SyntaxError: missing ) after argument list
0|pnpm  |     at Object.compileFunction (node:vm:353:18)
0|pnpm  |     at wrapSafe (node:internal/modules/cjs/loader:1040:15)
0|pnpm  |     at Module._compile (node:internal/modules/cjs/loader:1076:27)
0|pnpm  |     at Module._extensions..js (node:internal/modules/cjs/loader:1166:10)
0|pnpm  |     at Module.load (node:internal/modules/cjs/loader:988:32)
0|pnpm  |     at Module._load (node:internal/modules/cjs/loader:834:12)
0|pnpm  |     at Object.<anonymous> (/home/ubuntu/.local/share/pnpm/global/5/.pnpm/pm2@5.2.0/node_modules/pm2/lib/ProcessContainerFork.js:33:23)
0|pnpm  |     at Module._compile (node:internal/modules/cjs/loader:1112:14)
0|pnpm  |     at Module._extensions..js (node:internal/modules/cjs/loader:1166:10)
0|pnpm  |     at Module.load (node:internal/modules/cjs/loader:988:32)

How could we reproduce this issue?

Just install pnpm https://pnpm.io/
And start an app with pnpm pm2 start pnpm -- run start

Supporting information

--- PM2 report ----------------------------------------------------------------
Date                 : Thu Aug 04 2022 17:10:19 GMT+0000 (Coordinated Universal Time)
===============================================================================
--- Daemon -------------------------------------------------
pm2d version         : 5.2.0
node version         : 18.4.0
node path            : /home/ubuntu/.local/share/pnpm/pm2
argv                 : /usr/bin/node,/home/ubuntu/.local/share/pnpm/global/5/.pnpm/pm2@5.2.0/node_modules/pm2/lib/Daemon.js
argv0                : node
user                 : ubuntu
uid                  : 1001
gid                  : 1001
uptime               : 0min
===============================================================================
--- CLI ----------------------------------------------------
local pm2            : 5.2.0
node version         : 18.4.0
node path            : /home/ubuntu/.local/share/pnpm/pm2
argv                 : /usr/bin/node,/home/ubuntu/.local/share/pnpm/global/5/node_modules/pm2/bin/pm2,report
argv0                : node
user                 : ubuntu
uid                  : 1001
gid                  : 1001
===============================================================================
--- System info --------------------------------------------
arch                 : arm64
platform             : linux
type                 : Linux
cpus                 : Neoverse-N1
cpus nb              : 4
freemem              : 24124837888
totalmem             : 25153310720
home                 : /home/ubuntu
===============================================================================
--- PM2 list -----------------------------------------------
┌────┬────────────────────┬──────────┬──────┬───────────┬──────────┬──────────┐
│ id │ name               │ mode     │ ↺    │ status    │ cpu      │ memory   │
└────┴────────────────────┴──────────┴──────┴───────────┴──────────┴──────────┘
[PM2][WARN] Current process list is not synchronized with saved list. App BaraSupremacy BaraSupremacyAPI BaraSupremacyClient BaraSupremacyTelegram differs. Type 'pm2 save' to synchronize.
===============================================================================
--- Daemon logs --------------------------------------------
/home/ubuntu/.pm2/pm2.log last 20 lines:
PM2        | 2022-08-04T17:08:44: PM2 log: PM2 successfully stopped
PM2        | 2022-08-04T17:10:19: PM2 log: ===============================================================================
PM2        | 2022-08-04T17:10:19: PM2 log: --- New PM2 Daemon started ----------------------------------------------------
PM2        | 2022-08-04T17:10:19: PM2 log: Time                 : Thu Aug 04 2022 17:10:19 GMT+0000 (Coordinated Universal Time)
PM2        | 2022-08-04T17:10:19: PM2 log: PM2 version          : 5.2.0
PM2        | 2022-08-04T17:10:19: PM2 log: Node.js version      : 18.4.0
PM2        | 2022-08-04T17:10:19: PM2 log: Current arch         : arm64
PM2        | 2022-08-04T17:10:19: PM2 log: PM2 home             : /home/ubuntu/.pm2
PM2        | 2022-08-04T17:10:19: PM2 log: PM2 PID file         : /home/ubuntu/.pm2/pm2.pid
PM2        | 2022-08-04T17:10:19: PM2 log: RPC socket file      : /home/ubuntu/.pm2/rpc.sock
PM2        | 2022-08-04T17:10:19: PM2 log: BUS socket file      : /home/ubuntu/.pm2/pub.sock
PM2        | 2022-08-04T17:10:19: PM2 log: Application log path : /home/ubuntu/.pm2/logs
PM2        | 2022-08-04T17:10:19: PM2 log: Worker Interval      : 30000
PM2        | 2022-08-04T17:10:19: PM2 log: Process dump file    : /home/ubuntu/.pm2/dump.pm2
PM2        | 2022-08-04T17:10:19: PM2 log: Concurrent actions   : 2
PM2        | 2022-08-04T17:10:19: PM2 log: SIGTERM timeout      : 1600
PM2        | 2022-08-04T17:10:19: PM2 log: ===============================================================================

@milosworks
Copy link
Author

Plus it has a lot of more issues with pnpm if you install pm2 with pnpm and can run an app if you use __dirname of esmodules the path is the pm2 path of pnpm XD

@dbrxnds
Copy link

dbrxnds commented Sep 30, 2022

Were you able to find a fix for this issue?

@milosworks
Copy link
Author

Were you able to find a fix for this issue?

No

@hanpei
Copy link

hanpei commented Mar 17, 2023

it's probably because you installed pnpm by homebrew。
you can try which pnpm, and find the pnpm linked path.
and run pm2 with the pnpm path, for example:
pm2 start /Users/{username}/Library/pnpm/global/5/.pnpm/pnpm@7.26.3/node_modules/pnpm -- start

or just install pnpm by npm globally

@milosworks
Copy link
Author

it's probably because you installed pnpm by homebrew。

you can try which pnpm, and find the pnpm linked path.

and run pm2 with the pnpm path, for example:

pm2 start /Users/{username}/Library/pnpm/global/5/.pnpm/pnpm@7.26.3/node_modules/pnpm -- start

or just install pnpm by npm globally

Thats incorrect, i installed pnpm by npm globally

@prime-voucher
Copy link

Any update?

@mm-webx
Copy link

mm-webx commented Apr 13, 2023

pm2 start pnpm -- run start

which pnpm in my case should be from asdf not from brew, so I used it like that asdf exec pnpm ... and worked.

@cryptiklemur
Copy link

Also happening for me:

--- PM2 report ----------------------------------------------------------------
Date                 : Thu Apr 27 2023 19:31:52 GMT-0500 (Central Daylight Time)
===============================================================================
--- Daemon -------------------------------------------------
pm2d version         : 5.3.0
node version         : 18.16.0
node path            : /home/aequasi/.local/share/pnpm/pm2
argv                 : /home/aequasi/.nvm/versions/node/v18.16.0/bin/node,/home/aequasi/.local/share/pnpm/global/5/.pnpm/pm2@5.3.0/node_modules/pm2/lib/Daemon.js
argv0                : node
user                 : aequasi
uid                  : 1000
gid                  : 1000
uptime               : 1min
===============================================================================
--- CLI ----------------------------------------------------
local pm2            : 5.3.0
node version         : 18.16.0
node path            : /home/aequasi/.local/share/pnpm/pm2
argv                 : /home/aequasi/.nvm/versions/node/v18.16.0/bin/node,/home/aequasi/.local/share/pnpm/global/5/node_modules/pm2/bin/pm2,report
argv0                : node
user                 : aequasi
uid                  : 1000
gid                  : 1000
===============================================================================
--- System info --------------------------------------------
arch                 : x64
platform             : linux
type                 : Linux
cpus                 : AMD Ryzen 9 7950X 16-Core Processor
cpus nb              : 32
freemem              : 29293117440
totalmem             : 33201926144
home                 : /home/aequasi
===============================================================================
--- PM2 list -----------------------------------------------
┌────┬────────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
│ id │ name       │ namespace   │ version │ mode    │ pid      │ uptime │ ↺    │ status    │ cpu      │ mem      │ user     │ watching │
├────┼────────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
│ 0  │ Discord    │ default     │ N/A     │ fork    │ 0        │ 0      │ 15   │ errored   │ 0%       │ 0b       │ aequasi  │ disabled │
│ 1  │ Twitch     │ default     │ N/A     │ fork    │ 0        │ 0      │ 15   │ errored   │ 0%       │ 0b       │ aequasi  │ disabled │
└────┴────────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘
===============================================================================
--- Daemon logs --------------------------------------------
/home/aequasi/.pm2/pm2.log last 20 lines:
PM2        | 2023-04-27T19:30:53: PM2 log: App [Discord:0] online
PM2        | 2023-04-27T19:30:53: PM2 log: App [Twitch:1] exited with code [1] via signal [SIGINT]
PM2        | 2023-04-27T19:30:53: PM2 log: App [Twitch:1] starting in -fork mode-
PM2        | 2023-04-27T19:30:53: PM2 log: App [Twitch:1] online
PM2        | 2023-04-27T19:30:53: PM2 log: App [Discord:0] exited with code [1] via signal [SIGINT]
PM2        | 2023-04-27T19:30:53: PM2 log: App [Discord:0] starting in -fork mode-
PM2        | 2023-04-27T19:30:53: PM2 log: App [Discord:0] online
PM2        | 2023-04-27T19:30:53: PM2 log: App [Twitch:1] exited with code [1] via signal [SIGINT]
PM2        | 2023-04-27T19:30:53: PM2 log: App [Twitch:1] starting in -fork mode-
PM2        | 2023-04-27T19:30:53: PM2 log: App [Twitch:1] online
PM2        | 2023-04-27T19:30:53: PM2 log: App [Discord:0] exited with code [1] via signal [SIGINT]
PM2        | 2023-04-27T19:30:53: PM2 log: App [Discord:0] starting in -fork mode-
PM2        | 2023-04-27T19:30:53: PM2 log: App [Discord:0] online
PM2        | 2023-04-27T19:30:53: PM2 log: App [Twitch:1] exited with code [1] via signal [SIGINT]
PM2        | 2023-04-27T19:30:53: PM2 log: App [Twitch:1] starting in -fork mode-
PM2        | 2023-04-27T19:30:53: PM2 log: App [Twitch:1] online
PM2        | 2023-04-27T19:30:53: PM2 log: App [Discord:0] exited with code [1] via signal [SIGINT]
PM2        | 2023-04-27T19:30:53: PM2 log: Script /home/aequasi/.local/share/pnpm/tsx had too many unstable restarts (16). Stopped. "errored"
PM2        | 2023-04-27T19:30:53: PM2 log: App [Twitch:1] exited with code [1] via signal [SIGINT]
PM2        | 2023-04-27T19:30:53: PM2 log: Script /home/aequasi/.local/share/pnpm/tsx had too many unstable restarts (16). Stopped. "errored"

@loganwoolf
Copy link

loganwoolf commented Jun 5, 2023

I was able to get around this issue by calling a script that runs the needed commands

$ pm2 start ~/launchers/strapi.sh

which ran this simple script

#!/bin/bash

cd ~/code/strapi-demo
pnpm develop

For reference, I had installed pnpm using its install script.

@LHC8888
Copy link

LHC8888 commented Jun 27, 2023

wow
it works for me in a nuxtjs project
run 👇
pnpm run dev

@christiancazu
Copy link

if you have pnpm installed globally, specify the interpreter to pm2
example:

pm2 start --interpreter ~/bin/bash myfile

or in your ecosystem.json set it

{
  "apps": [
    {
      "name": "myapp",
      "script": "pnpm",
      "args": "start",
      "interpreter": "/bin/bash"
    }
  ]
}

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

9 participants