Can not get 'required' to work

I must be missing something really simple. I need to ‘require’ another library.
I have added to the top of my index.js file

`const { getTokenFromGCPServiceAccount } = require('')`

and I have run

`npm i`

on my command line and I can see that it has added it under a node_modules directory.
When I run the code I get the following error:

ReferenceError: require is not defined

I know it must be something simple that I am missing as I can’t find anyone else with the same issue in relation to cloudflare workers. I have tried several example scripts too and whenever require or import is used I can’t get it to work :frowning:

Please put me out of my misery.


Thank you. That’s a really helpful pointer. I’m following this tutorial so hopefully the node packages will work:
You said “read this:” but there was no link. I assume it was intended to be a link to the webpack docs on the workers site.

Unfortunately Discourse doesn’t include embeds in quotes. If you click the title of the post it’ll go to the original with a link to the webpack docs, just as you said.