-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Error run .mjs file #4591
Comments
Which pm2 version? |
2.9.2-next |
upgrade to latest
it will works |
I did as you wrote and now I got another error After run the script every a few seconds appears two dos screens and they hide immediately and it happens constantly until I stop the script by a command.
|
Could you share me a sample app so I can try this |
This is a test project for testing pm2. |
Any updates? |
I'm also seeing this, although I'm using Node 12.16.1 (LTS) which doesn't require the .mjs extension. I have
and the error:
|
I had to patch pm2 v4.4 on my PC to solve this - issue is that path.resolve() returns "c:..." on Windows, and the ESM "import" does not accepts it. I had to patch pm2\lib\ProcessContainer.js with this (discusting) code: |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
@AndrewIsh I'm facing the same issue, have you got this issue fixed? |
I ended up side stepping the whole thing by switching from |
Oh well, that's definitely not an option for me :( Hope someone can get mjs to work on node 12.18 and pm2 4.4.0. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
@tnokin thanks, I had to change your code a little to this in pm2\lib\ProcessContainer.js if (ProcessUtils.isESModule(script) === true){ |
I'm guessing PM2 doesn't support ESM on Windows. For those in a pinch, https://github.com/coreybutler/node-windows after you install it as a service. |
Is there a plan for fixing this issue at all since we are experiencing the same behavior? |
Sad this isn't supported. It'd be really nice to be able to use standard Node features in apps even when running through pm2. |
I also had the same issue, the workaround I found is to use I run a discord bot and for some reason if I add I've also tried to run |
Thanks @SammyWhamy, that worked for me on Windows 10, node v14.8.0, pm2 v4.4.1 |
thanks @SammyWhamy , use |
oh ,on,how can we used pm2 start a project with the ecosystem.config.js. |
Added Was able to get it fixed by renaming |
谢谢,在liunx上没有问题 |
Not sure why it doesn't work even with the latest pm2 |
This chunk of code should be fixed. In case of https://github.com/Unitech/pm2/blob/master/lib/Common.js#L314-L318 else if (filename.indexOf('.config.js') > -1 || filename.indexOf('.config.cjs') > -1 || filename.indexOf('.config.mjs') > -1) {
var confPath = require.resolve(path.resolve(filename));
delete require.cache[confPath];
return require(confPath);
} |
Fixed in #5524. Please close. |
@orgads Which version contains the fix? |
5.3.0. |
What's going wrong?
When I run pm2 start index.mjs -e logs/err.log I get an error
index.mjs
package.json
ecosystem.config.mjs
How could we reproduce this issue?
The text was updated successfully, but these errors were encountered: