import.meta
An object available inside an ES module that describes the module itself; import.meta.url is the file:// URL of the current file.
In more detail
It replaces CommonJS's __filename and __dirname. Recent Node.js versions also offer import.meta.filename and import.meta.dirname directly.
Related terms
- ECMAScript modules — The standard JavaScript module system, written with import and export statements, used by browsers and modern tools.
- file URL — A URL starting with file:// that points at a file on the local disk; Node.js identifies ES modules by these.
Taught in
- Native Module Systems: ESM Loader Hooks vs CommonJS — Node.js Internals & Backend Services