文件网址路径


【File URL paths】

对于大多数 node:fs 模块函数,pathfilename 参数可以通过 file: 协议作为 <URL> 对象传递。

【For most node:fs module functions, the path or filename argument may be passed as a <URL> object using the file: protocol.】

import { readFileSync } from 'node:fs';

readFileSync(new URL('file:///tmp/hello')); 

file: URL 总是绝对路径。