Skip to content

ToNamespacedPath doesn't work with device names #54180

Description

@rotu

Version

v20.16.0

Platform

Microsoft Windows NT 10.0.22635.0 x64

Subsystem

No response

What steps will reproduce the bug?

import path from 'node:path'
console.log(path.toNamespacedPath("COM3"))

How often does it reproduce? Is there a required condition?

Every time.

What is the expected behavior? Why is that the expected behavior?

This should print:

\\.\COM3

which is the fully qualified path in the device namespace

What do you see instead?

This prints the illegal path:

\\?\C:\Users\dan\COM3

Additional information

Reference for legal path name: https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#win32-device-namespaces
Additionally console.log(url.pathToFileURL("COM3").href) prints an invalid URL, but I'm not sure if there is a corresponding valid file: URL.

Activity

  1. added
    pathIssues and PRs related to the path subsystem.
    on Aug 2, 2024
  2. added
    windowsIssues and PRs related to the Windows platform.
    on Aug 2, 2024
  3. github-actions commented on Apr 29, 2026

    @github-actions
    Contributor

    This issue has been marked as stale due to 210 days of inactivity.
    It will be automatically closed in 30 days if no further activity occurs. If this is still relevant, please leave a comment or update it to keep it open.

  4. added
    staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.
    on Apr 29, 2026
  5. rotu commented on Apr 29, 2026

    @rotu
    Author

    Not stale.

  6. removed
    staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.
    on Apr 30, 2026
  7. github-actions commented on Jul 30, 2026

    @github-actions
    Contributor

    This issue has been marked as stale due to 90 days of inactivity.
    It will be automatically closed in 30 days if no further activity occurs. If this is still relevant, please leave a comment or update it to keep it open.

  8. added
    staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.
    on Jul 30, 2026
  9. rotu commented on Jul 30, 2026

    @rotu
    Author

    not stale

  10. removed
    staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.
    on Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    pathIssues and PRs related to the path subsystem.windowsIssues and PRs related to the Windows platform.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions