Module not found error when k6 fails to resolve a local import
0 reputation · 10 Oct 2023, 12:12 UTC
When running a k6 test that imports a local JavaScript module, the tool aborts with a “module not found” error before any virtual users start.
The goal is to understand exactly how k6’s ES‑module resolver determines the file location for relative imports, especially when the test is launched from a directory different from the test file or when symlinks are involved.
Constraints include the resolver’s reliance on the test entry point as the base, possible variations across operating systems, and the lack of explicit documentation on whether NODE_PATH or custom path aliases affect resolution.
Does k6 resolve imports relative to the test file’s directory or the current working directory? How does it behave with symlinked files or Windows‑style path separators? Is there a mechanism to inspect the resolved module graph before test execution?