file URL
A URL starting with file:// that points at a file on the local disk; Node.js identifies ES modules by these.
In more detail
fileURLToPath() from node:url turns one into an ordinary path for the current platform, and pathToFileURL() does the reverse. Using URLs lets the same module specifiers work in browsers and servers.
Related terms
- URL — A web address, such as https://example.com/docs, made of a scheme, a host, an optional port and a path.
- 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.
- ECMAScript modules — The standard JavaScript module system, written with import and export statements, used by browsers and modern tools.
Taught in
- Native Module Systems: ESM Loader Hooks vs CommonJS — Node.js Internals & Backend Services