import.meta is a meta property: syntax, not a variable lookup, and it is a SyntaxError outside a module (in CommonJS you get Cannot use 'import.meta' outside a module). Each module has its own object: the engine creates a null-prototype object the first time the module reads it, asks the host to fill in properties, caches it, and returns the same object on every later read. It is extensible, so you can add properties.
The language specifies no properties. By convention, hosts provide:
import.meta.url: the module's absolute URL. In browsers it is the script's URL (for an inline module, the document's URL); in Node.js it is afile:URL.import.meta.resolve(specifier): resolves a specifier the wayimportwould, relative to this module, and returns a URL string. It does not load anything and, in Node.js, returns a string synchronously.import.meta.filenameandimport.meta.dirname(Node.js only): the absolute path of the file (symlinks resolved) and its directory, available forfile:modules. They replace CommonJS__filenameand__dirname.import.meta.main(Node.js):truein the entry module, the counterpart torequire.main === module. Node.js documents it as Stability 1.0, early development.
The common job is finding files next to the module. Relative paths in fs calls resolve against the working directory, not the module, so build the location from import.meta.url or dirname.