-
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
PM2 unable to run ESM packages: ERR_UNSUPPORTED_ESM_URL_SCHEME #4839
Comments
This commit fixes issue Unitech#4839
published in [email protected] npm install pm2@latest -g |
Hi @ox-harris, Any special steps on how to make use of this fix? EDIT: Nevermind, fork mode works, that was just me reading the logs wrong, but the problem in |
This commit fixes issue Unitech#4839
@Unitech, unfortunately this issue is still relevant for Please, fix the incompatibility to be able use the full potential of |
Same problem with cluster mode v5.1.0 Node 16.5 Windows 10 |
I was experiencing this error being thrown from another file, ProcessContainer.js, but my workaround was to look for the usage of "process.env.pm_exec_path" that it is choking on in the pm2 library files, and it replace it with the string path to your script. It will auto-append your drive letter, so just start the path with a slash. i.e. import(process.env.pm_exec_path); Just be sure to remember to revert the pm2 change you've made! Or that could get confusing real fast. |
What's going wrong?
In this version of pm2 (v4.4.1),
pm2.start ('reference/to/esm-package/script.js')
is throwing the following error inerr.log
file: Error[ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only file and data URLs are supported by the default ESM loader
The stack trace reveals the problem to be with the ESM script loader in
lib\ProcessContainerFork.js:29:24
. There the import statement is attempting to import the ESM script using the file path instead of a file scheme.How could we reproduce this issue?
Try starting a script within an ES module package:
pm2.start ('reference/to/esm-package/script.js')
, then find the error in theerr
file for the process.Supporting information
PM2 version: v4.4.1
Node version: v13.7.0
OS: windows
I wouldn't mind submitting a PR for a fix. It simply requires converting the given path to a file URL using
url.pathToFileURL()
.So, instead of
import(process.env.pm_exec_path);
, we should now haveimport(url.pathToFileURL(process.env.pm_exec_path));
The text was updated successfully, but these errors were encountered: