Skip to content

fs.fileReadSync doesn't understand file:// URL strings #20357

@ravinggenius

Description

@ravinggenius
  • Version: 10.0.0
  • Platform: Darwin dionysus.local 17.5.0 Darwin Kernel Version 17.5.0: Mon Mar 5 22:24:32 PST 2018; root:xnu-4570.51.1~1/RELEASE_X86_64 x86_64
  • Subsystem: fs

Description

Assume /tmp/foo.txt exist. Reading the file with fs.fileReadSync('/tmp/foo.txt') works as expected, but using fs.fileReadSync('file:///tmp/foo.txt') fails to read the file.

Why it matters

I need to read files relative to the current file, but __dirname/__filename are not available when parsing modules. I can compute __dirname with import.meta.url by passing it to path.dirname, but the path is still prefixed with file://.

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateIssues and PRs that are duplicates of other issues or PRs.fsIssues and PRs related to the fs subsystem / file system.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions