MV How to run a script before any normal event/common event?

I've the need to run a specific line of code EXACTLY before any normal or common event runs in a given map. Anyone knows how to?

This is for a project of mine, where I've the need to, after loading into a specific user-customized map, I need to be able to "turn off" node.js features, by running require=undefined. I've tried to run it before running the reserveTransfer to said map, but for some reason it has started to cause issues that I cannot trace, so I would imagine this approach would be better

Original thread: https://forums.rpgmakerweb.com/threads/how-to-run-a-script-before-any-normal-event-common-event.138707/