Skip to content

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

@thrandale

Description

@thrandale

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

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions