Path relative to the module directory
import.meta.url (ESM) or __filename (CJS)
Absolute resolved path.
Useful for loading internal assets such as:
.hbs templatesUnlike process.cwd(), this resolves relative to the module file location, making it safe for usage inside node_modules.
The relativePath must follow strict rules:
Allowed:
./file → same directory../file → one level up (only one ../ allowed)/file → absolute pathfile/... → normal relative paths (no leading ./)Disallowed:
../../file)a/../file)../These constraints help prevent directory traversal vulnerabilities.
Resolves a path relative to the provided module's directory.