Require doesn't work with a template literal

If you try to use

module = require(`module`)

RunKit will give you an error saying the module cannot be found. Node.js supports this, so I would consider this a bug.

When did you try this? This is working for me:

Okay that was just a generic name I used for demonstrative purposes, but apparently it’s also a built-in module. Also, I guess it does work with built-in modules. The problem is when trying to get an npm package.

Ah yes! Can reproduce now. I know what’s going on too, but won’t get a chance to get to it until next week probably, but once I do it should be relatively straight forward (I can think of one or two possible weird issues). Hopefully it’s not too much of a headache to use non-template strings till then.

1 Like

Hi Ursi,

We’ve gone ahead and added support for template string literals, so it should be working now. One caveat is that this only works if you don’t use string interpolation, as RunKit doesn’t currently support dynamic requires.

https://runkit.com/me1000/5d68601d425f59001bc2a063

Thank you for bringing this to our attention. Please let us know if you run into any other issues.

- Randy

1 Like