DEV Community

LG
LG

Posted on

Node.js module system + purge the cache for CJS

Follow comments carefully within code source . A few important assumptions emphasized tho :

  • module .require(d) synchronously
  • module cached the very first time it's required : every subsequent require will point to the same module's reference
  • not possible to require() files that have the .mjs extension : attempting to do so will throw an error as it's reserved for ESM

References:

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more