pm2
pm2 copied to clipboard
pm2 not working with esm on windows 10, there are no workarounds!
What's going wrong?
https://github.com/Unitech/pm2/issues/4688 Issue is closud but not solved, now it is not possible to use pm2 on windows 10 with esm modules.
How could we reproduce this issue?
Try to run nodejs script in esm module format
Supporting information
PS D:\vrnet\VRnet\web\add> pm2 report
--- PM2 report ---------------------------------------------------------------- Date : Tue Aug 18 2020 20:14:39 GMT+0300 (Москва, стандартное время)
--- Daemon ------------------------------------------------- pm2d version : 4.4.1 node version : 14.8.0 node path : not found argv : D:\Program Files\nodejs\node.exe,C:\Users\Forux\AppData\Roaming\npm\node_modules\pm2\lib\Daemon.js argv0 : node user : undefined uid : N/A gid : N/A uptime : 55min
--- CLI ---------------------------------------------------- local pm2 : 4.4.1 node version : 14.8.0 node path : not found argv : D:\Program Files\nodejs\node.exe,C:\Users\Forux\AppData\Roaming\npm\node_modules\pm2\bin\pm2,report argv0 : D:\Program Files\nodejs\node.exe user : Forux
--- System info -------------------------------------------- arch : x64 platform : win32 type : Windows_NT cpus : Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz cpus nb : 8 freemem : 19485593600 totalmem : 34235043840 home : C:\Users\Forux
--- PM2 list ----------------------------------------------- ┌─────┬───────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐ │ id │ name │ namespace │ version │ mode │ pid │ uptime │ ↺ │ status │ cpu │ mem │ user │ watching │ └─────┴───────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘
--- Daemon logs -------------------------------------------- C:\Users\Forux.pm2\pm2.log last 20 lines: PM2 | 2020-08-18T20:02:48: PM2 log: pid=14132 msg=process killed PM2 | 2020-08-18T20:02:48: PM2 log: App [uploadModels:0] starting in -fork mode- PM2 | 2020-08-18T20:02:48: PM2 log: App [uploadModels:0] online PM2 | 2020-08-18T20:02:53: PM2 log: [Watch] Stop watching uploadModels PM2 | 2020-08-18T20:02:53: PM2 log: Stopping app:uploadModels id:0 PM2 | 2020-08-18T20:02:53: PM2 log: App [uploadModels:0] exited with code [1] via signal [SIGINT] PM2 | 2020-08-18T20:02:53: PM2 log: pid=17164 msg=process killed PM2 | 2020-08-18T20:02:54: PM2 log: [Watch] Start watching uploadModels PM2 | 2020-08-18T20:02:54: PM2 log: App [uploadModels:0] starting in -fork mode- PM2 | 2020-08-18T20:02:54: PM2 log: App [uploadModels:0] online PM2 | 2020-08-18T20:04:31: PM2 log: Change detected on path server.log for app uploadModels - restarting PM2 | 2020-08-18T20:04:31: PM2 log: Stopping app:uploadModels id:0 PM2 | 2020-08-18T20:04:31: PM2 log: App [uploadModels:0] exited with code [1] via signal [SIGINT] PM2 | 2020-08-18T20:04:31: PM2 log: pid=22556 msg=process killed PM2 | 2020-08-18T20:04:31: PM2 log: App [uploadModels:0] starting in -fork mode- PM2 | 2020-08-18T20:04:31: PM2 log: App [uploadModels:0] online PM2 | 2020-08-18T20:04:36: PM2 log: [Watch] Stop watching uploadModels PM2 | 2020-08-18T20:04:36: PM2 log: Stopping app:uploadModels id:0 PM2 | 2020-08-18T20:04:37: PM2 log: App [uploadModels:0] exited with code [1] via signal [SIGINT] PM2 | 2020-08-18T20:04:37: PM2 log: pid=12156 msg=process killed
Please copy/paste the above report in your issue on https://github.com/Unitech/pm2/issues
Is this by design? Can it not be fixed?
Would be nice if this got addressed...
Workaround: go to to the pm2 package file with the single failure and hardcode the path to your script, without a drive letter, instead of the variable it's using. It's choking on the "C:" path it's getting. Since this is such a small point of failure, it would be really great if the pm2 team could address it.
Hi @rujiel Please where is this package file located
Hi @rujiel Please where is this package file located
In this file
C:\Program Files\nodejs\node_modules\pm2\lib\ProcessContainer.js
line 301 needs a path (with no drive letter) rather than the variable it's getting:
import('/path/to/index.mjs');
i found a fix at node_modules\pm2\lib\ProcessContainer.js line 301 replace it with the following code with this below
import(require('url').pathToFileURL(process.env.pm_exec_path));
hope it help
Nice, can you do a pull request please?
Nice, can you do a pull request please?
I was going to until I found out someone already done it https://github.com/Unitech/pm2/pull/5291
oh, killer. thank you!
Nice, can you do a pull request please?
I was going to until I found out someone already done it #5291
The PR was closed with no indication as to why...
i found a fix at node_modules\pm2\lib\ProcessContainer.js line 301 replace it with the following code with this below
import(require('url').pathToFileURL(process.env.pm_exec_path));hope it help
It helps me a lot! :) Just in case anyone has a similar instalation than me, I found the ProcessContainer file in this direction: C:\Users<YOUR_USER>\AppData\Roaming\npm\node_modules\pm2\lib
Is this issue solved in the latest versions of pm2?
Yes, it is
On Mon, Oct 10, 2022, 9:01 AM Riyazur Razak N @.***> wrote:
Is this issue solved in the latest versions of pm2?
— Reply to this email directly, view it on GitHub https://github.com/Unitech/pm2/issues/4819#issuecomment-1273528338, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABF2LHUWB5X2TPNBG7WBA43WCQ4VDANCNFSM4QDZVMZQ . You are receiving this because you were mentioned.Message ID: @.***>
Well looks like this issue is still not solved so have to fix on the global installation.
This has been solved in https://github.com/Unitech/pm2/pull/5524
https://github.com/Unitech/pm2/releases/tag/5.3.0