MV Using "require" to import libraries in RMMV

When I tried to use "require" function to import an external library called "events" in my plugin .js file, I found that it worked fine in developer mode while it failed in distributed mode. Plz help.

Here is my code:
JavaScript:
const EventEmitter = require("events");
Unfortunately, RPG Maker is not well prepared for the "require" keyword but builds on so-called plugins. You need to get the code of "events" somehow and import it just as you import a regular plugin or paste the code into your plugin.
Unfortunately, RPG Maker is not well prepared for the "require" keyword but builds on so-called plugins. You need to get the code of "events" somehow and import it just as you import a regular plugin or paste the code into your plugin.
Thanks a lot!

Original thread: https://forums.rpgmakerweb.com/threads/using-require-to-import-libraries-in-rmmv.171787/