Skip to content

node inspect hides inspect.js script without warning #64111

Description

@vassudanagunta

Version

v26.3.0

Subsystem

node inspect

What steps will reproduce the bug?

echo "console.log('executing respect.js')" > respect.js

echo "console.log('executing inspect.js')" > inspect.js

node respect arg

node inspect arg

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

Either a hard error:

$ node respect arg
executing respect.js

$ node inspect arg
AMBIGUITY ERROR: A script named "inspect.js" exists in the current directory.
Unsure whether user intends to run the script or invoke the Node debugger.
To run the script, use "node inspect.js". To run the debugger, the script must
first be renamed.

or a warning:

$ node inspect arg
WARNING: The 'inspect' subcommand is overriding the script "inspect.js" in
  the current directory. To execute the script, use "node test.js".

(debugger output starts here)

Reason: See

What do you see instead?

$ node respect arg
executing respect.js

$ node inspect arg
< Debugger listening on ws://127.0.0.1:9229/3361b133-b551-4d82-954d-9f3b73993558
< For help, see: https://nodejs.org/learn/getting-started/debugging
< 
< Debugger attached.
< 
 ok
< Waiting for the debugger to disconnect...
< 
debug> 

Additional information

No response

Activity

  1. DSAntonio08 commented on Jul 1, 2026

    @DSAntonio08

    Hi! I'd be interested in working on this, but before I start — the issue mentions two possible fixes (hard error vs. warning). Given the linked discussions around node run/node inspect being reserved subcommands, is there already a preferred direction from the maintainers, or is this still open for either approach?

  2. bitpshr commented on Jul 12, 2026

    @bitpshr
    Contributor

    Opened #64448 for this. I went with a warning rather than a hard error, since erroring would break running the debugger from a directory that just happens to contain an inspect.js. Happy to switch it to an error if that's the preferred direction.

  3. aduh95 commented on Jul 12, 2026

    @aduh95
    Contributor

    I really don't think it's worth fixing, there are many other "shadowing" happening (e.g. if you have a file and a directory with the same name, the file shadows the directory and you don't hear anyone complaining about it). It's like a quirk, sure it can be surprising but we don't recommend not providing the file extension, omitting it is asking for trouble

  4. vassudanagunta commented on Jul 13, 2026

    @vassudanagunta
    ContributorAuthor

    @aduh95

    The issue of shadowing is the primary thing holding up the introduction of additional subcommands beyond node inspect. Please see @tniessen's comment at the first link I provided. I am on the verge of publishing a proposal for subcommands that I hope will answer his call: "If someone is inevitably going to add subcommands to Node.js, we should at least have a policy for that, and a strategy that goes beyond a single subcommand."

    In fact, I submitted this issue as a part of my R&D for the proposal, which includes a number of possible solutions to smoothly if not elegantly address this issue, the anti-pattern of which @tniessen's speaks.

    Would you please consider reopening this issue at least for a couple of weeks, as I think it should be part of the discussion I hope occurs about subcommands?

  5. aduh95 commented on Jul 13, 2026

    @aduh95
    Contributor

    Shadowing local files would still be a reality whether we issue a warning or not, so introducing subcommands would not be less breaking if that issue stays open

    which includes a number of possible solutions to smoothly if not elegantly address this issue

    I’d be curious to see those solutions, we should probably start with those instead

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions