Closed
Description
using --experimental-modules
We could improve the documentation:
import.meta.url
is not an equivalent of __dirname
several lines of code are required to make it work.
Here's my current workaround, if you have a better way of doing please share:
import path from "path";
// same as previous __dirname, substring(8) removes the file:/// that is at the beginning
const dirname__ = path.dirname(import.meta.url.substring(8));
const x = readFileSync(`${dirname__}/x.html`, `utf8`);
Describe the solution you'd like
Add a few lines in the doc on how to transition from __dirname to import.meta.url
Describe alternatives you've considered
Otherwise provide import.meta.__dirname
for even easier transition
Metadata
Metadata
Assignees
Labels
No labels