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 not working with esm on windows 10, there are no workarounds! #4819

Open
Forux opened this issue Aug 18, 2020 · 15 comments
Open

pm2 not working with esm on windows 10, there are no workarounds! #4819

Forux opened this issue Aug 18, 2020 · 15 comments

Comments

@Forux
Copy link

Forux commented Aug 18, 2020

What's going wrong?

#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
@yinonby
Copy link

yinonby commented Nov 17, 2020

Is this by design? Can it not be fixed?

@ctrlsam
Copy link

ctrlsam commented Feb 1, 2021

Would be nice if this got addressed...

@rujiel
Copy link

rujiel commented Oct 25, 2021

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.

@NathBabs
Copy link

Hi @rujiel Please where is this package file located

@rujiel
Copy link

rujiel commented Feb 15, 2022

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');

@zane0703
Copy link

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

@rujiel
Copy link

rujiel commented Feb 21, 2022

Nice, can you do a pull request please?

@zane0703
Copy link

Nice, can you do a pull request please?

I was going to until I found out someone already done it
#5291

@rujiel
Copy link

rujiel commented Feb 22, 2022

oh, killer. thank you!

@maxijonson
Copy link

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...

@Lucas-rd
Copy link

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

@RiyazurRazak
Copy link

Is this issue solved in the latest versions of pm2?

@rujiel
Copy link

rujiel commented Oct 10, 2022 via email

@ShueiYang
Copy link

Well looks like this issue is still not solved so have to fix on the global installation.

@kehwar
Copy link

kehwar commented Sep 19, 2023

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