K6/crypto throwing error during run

I am using the k6/crypto module but on run I am suddenly getting an odd error:

WARN[0000] The moduleSpecifier "crypto" has no scheme but we will try to resolve it as remote module. This will be deprecated in the future and all remote modules will need to explicitly use "https" as scheme.

I am importing and using it pretty normally:

import crypto from 'k6/crypto';

getUUID(): string {
    const uuid = crypto.md5(crypto.randomBytes(42), 'hex');
    return uuid;
  }

I can’t find where this is coming from - I’m using webpack with typescript and I think perhaps that is where my issue is coming from, I’m new to webpack so it could be how I am loading it?

  externals: /^(k6|https?\:\/\/)(\/.*)?/,

I’m kind of lost at this point but any help would be greatly appreciated!

Hi @hhamdy,

Given the error message this is unlikely to be due to the line

import crypto from 'k6/crypto';

It seems like you are import crypto not k6/crypto somewhere.

Maybe that is done through some polyfill from webpack.

Can you provide a fuller code sample, preferably with the commands to reproduce it.

Also are you using GitHub - grafana/k6-template-typescript: Template to use TypeScript with k6 ?

This helped immensely! I was using the target of node instead of web which seemed to pull all externals. I made some changes to how I build files and what imports I use and now the test runs without the crypto warning.

Thanks!