I want to use the same instance of EventEmitter, as well as constants, in my Remix server code and my express server file. Is this possible?
Using Remix Routing V2, my relevant file structure is:
project
└───app
│ └───routes
│ │ constants.ts
│ │ emitter.server.ts
└───server.mjs
The file emitter.server.ts merely imports EventEmitter and exports a new instance of it. Both my route loaders and my server file need access to that same EventEmitter instance (and access to constants as an aside).
Attemtping to import the emitter into my express server file like this results in the following error:
import { emitter } from './app/emitter.server.ts'
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/usr/app/app/emitter.server' imported from '/user/app/server.mjs
Notes:
- I'm using
esmsyntax for myserver.mjsfile (import instead of require). - serverModuleFormat in remix.config.ts is
cjs - I don't have
"type": "module"inpackage.jsonbecause I'm using@muilibraries and that blows up all the@muiimports - I was using
cjssyntax inserver.jsuntil recently. I changed toesmsyntax, which required changing its file type fromjstomjs - No idea if any of these are important
Thanks for taking a look.