How to Use Imports with createRequire in Production Deployment?

This topic was automatically generated from Slack. You can find the original thread here.

ive used this code to do require’s in a file using imports and it worked locally, but not in PD. i assume that’s something i’ll need to figure out, right?

import { createRequire } from "module";
const require = createRequire(import.meta.url);

What’s the error you’re seeing? And could you tell me more about the use case for needing to do requires inside of an ESM module?

hey - sorry - i ended up NOT using the npm module that didn’t support es6 imports and switched to one that did. which i guess sounds obvious, but the first module was very easy, so i was hesitant to try switching. i got it all working :slightly_smiling_face:

nice!