Understand directory and specifier terminology
mainTo use the resolver correctly, understand these two core concepts:
directory: An absolute path to a directory where the specifier is resolved against.- For CommonJS, this is typically the
__dirnameof the current module. - For ESM, this is the value of
import.meta.url. - Note: Providing a path to a file instead of a directory results in undefined behavior.
- For CommonJS, this is typically the
specifier: The string passed to a module loading function, such as the argument inrequire("specifier")orimport "specifier".