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

Error [ERR_UNSUPPORTED_ESM_URL_SCHEME] when using a artillery runner file with a .mjs extension #2661

Open
thrandale opened this issue Apr 22, 2024 · 0 comments

Comments

@thrandale
Copy link

Artillery is supposed to support ES Modules. Per the documentation, the way of doing this is to have your artilleryRunner file have the .mjs extension instead of the .js extension. I am using an artillery.yaml file to pass in the processor:

config:
  ...
  processor: "artilleryRunner.mjs"
  ...

When running artillery it gives the error Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only URLs with a scheme in: file, data, and node are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:'

In doing some tracing, this error is Coming from core/lib/runner.js when it is trying to load the artilleryRunner.mjs file. Per this) Stack Overflow Post: the import() function [only works with file:// and data:// URLs](https://nodejs.org/api/errors.html#err_unsupported_esm_url_scheme), but path.resolve() only returns an absolute path (not a URL)

This can be fixed by doing a pathToFileURL() before doing the import() of the module

Version info:

Artillery: 2.0.10
Node.js:   v18.17.1
OS:        win32
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

1 participant