import.meta
¶
The import.meta
meta property is an Object
that contains the following properties.
import.meta.url
¶
This is defined exactly the same as it is in browsers providing the URL of the current module file.
This enables useful patterns such as relative file loading:
import.meta.resolve(specifier[, parent])
¶
Stability: 1 - Experimental
This feature is only available with the --experimental-import-meta-resolve
command flag enabled.
specifier
The module specifier to resolve relative to parent
.parent
| The absolute parent module URL to resolve from. If none is specified, the value of import.meta.url
is used as the default.- Returns:
Provides a module-relative resolution function scoped to each module, returning the URL string.
import.meta.resolve
also accepts a second argument which is the parent module from which to resolve from:
This function is asynchronous because the ES module resolver in Node.js is allowed to be asynchronous.