Error about mounting the local directory

Hi All, Im new to K6. I have set up the framework and added a script to access a page to add a job.
I have followed this documentation (Performance Testing with Generated Data using k6 and Faker - DEV Community) for data parameterisation. I have added subscriber.js in a folder. Called this file in my script. My purpose is to run the script using this file ‘n’ number of times where n is the number of users that I specified in my load profile file for certain amount of duration. Im running this on my local mac using docker. When I tried running the script, I have received the below error:

ERRO[0000] The moduleSpecifier “./subscriber” couldn’t be found on local disk. Make sure that you’ve specified the right path to the file. If you’re running k6 using the Docker image make sure you have mounted the local directory (-v /local/path/:/inside/docker/path) containing your script and modules so that they’re accessible by k6 from inside of the container, see Modules.

I have googled and ran this command “docker run --rm -v /home/k6/example/src:/src -i grafana/k6 run /src/index.js” (I think I need to change the path but Im not sure)

Could some one please explain where Im going wrong and help me correct it.

I have basic knowledge in JS and K6.

thank you.

Hi @gnarenmba !

Sorry for the delay in the reply :frowning_face:

yeah, you probably should specify a correct path to a folder where your scripts are located (index.js and subscriber.js). So instead of the /home/k6/example/src, please use your absolute local. Or, if you are currently in the folder with the scripts, then you can run it like this:

docker run --rm -i -v "$PWD:/src" grafana/k6 run /src/index.js

Let me know if that helps!