import.meta.url
- 类型:<string> 模块的绝对
file:URL。
这与在浏览器中提供当前模块文件的 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 { readFileSync } from 'node:fs';
const buffer = readFileSync(new URL('./data.proto', import.meta.url));