I am trying to host a Node.js (Express) app at DreamHost using shared unlimited plan. I was able to do most of the work. There is only one problem, DreamHost uses Passenger to run Node.js apps, and Passenger does not support Node 14+, so I have to stick with Node 12.
The Express project I was building is built on TypeScript and I used Node 16 to do all of the stuff (installing, running, etc.). When I build the TypeScript, it uses an NPM package exit-free-leak which uses FinalizationRegistry, hence requires Node v14+.
So after building the app, when I run the app.js with Node 12 it gives me the error that FinalizationRegistry is not defined. For now I am getting this error, but the exit-free-leak uses another Node 14+ function WeakRef.
How do I get around this issue while using Node 12? Is there any way to polyfill these functions or disable use of the package exit-free-leak using tsconfig.json, or maybe an even better solution?
Unfortunately the answer to "how do I get around this issue while using node v12" is probably: "you don't".
Node 12 has been end-of-life for 9 months; given how fast the JavaScript ecosystem moves in general, it's unlikely that libraries will keep supporting that version for very long anyway.
You'd be best off asking Dreamhost about Node 16 or 18 support, or move elsewhere if they can't provide you with up-to-date runtimes that still get security updates.