Skip to content

About require function #49345

Closed Answered by bnoordhuis
raccoon666666 asked this question in General
Discussion options

You must be logged in to vote

require() resolves paths relative to the module that calls it. A single global require() doesn't know what module calls it, not in enough detail to function properly.

It's technically possible to reconstruct the caller's details through V8's C++ API but that's slower and more complicated than an IIFE.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by RedYetiDev
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants