Function crashed: Runtime.ImportModuleError - Error: Cannot find module 'eventemitter3'


my site won’t build:

My repo is public: GitHub - Scatter-Partners/milady-aura-petz: Minting Dapp for Milady Aura Petz

I tried adding the eveentemitter3 package to external_node_modules: milady-aura-petz/netlify.toml at master · Scatter-Partners/milady-aura-petz · GitHub

I ensured it’s a production dependency in package.json: milady-aura-petz/package.json at master · Scatter-Partners/milady-aura-petz · GitHub

No build problems reported. Any other tips please?

I believe this is a problem specifically related to the Remix framework I’m using.

I was able to fix it by creating a file like this:


export { default } from "eventemitter3";

Then I imported it in an action like this:

import EventEmitter from "~/utils/eventemitter.server";

export const action: ActionFunction = async ({ request, context }) => {
  const EE = new EventEmitter();

I think that forces the package into the server bundle.

Hiya! Thanks for sharing your solution with the community!

1 Like