Language concepts

import.meta

Try the free JavaScript compiler

A module meta-property exposing host-defined metadata. Its available properties vary by runtime; it is not available in classic scripts. Multi-file example: save each listed file separately, then run the entry file with Node.js. See the packaged fixture for the original files.

Formal Syntax & Structure

javascript syntaxjavascript
import.meta

Working Example

Example Snippetjavascript
// File: main.mjsconst url = new URL("./data.json", import.meta.url);console.log(import.meta.url.endsWith("/main.mjs"), url.pathname.endsWith("/data.json"));
JavaScript Reference