Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Fixed an issue with files named node.js on Windows #64

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

giovannicalo
Copy link

When a Node module binary is run in a folder containing a file called node.js, on Windows, that file will be opened instead of the binary.

This happens due to Windows' PATHEXT environment variable containing .JS.

The issue was originally fixed in 8b1433c, but it has reappeared in c039646.

Currently, endlocal is called after editing PATHEXT but before invoking Node, so the latter is not affected by it.

My solution edits PATHEXT after calling endlocal, thus affecting the Node invocation and fixing the issue.

The only downside is the Node process will receive the edited PATHEXT, which however must've been the original behaviour anyway.

@giovannicalo giovannicalo requested a review from a team as a code owner April 18, 2022 02:25
@giovannicalo giovannicalo changed the title Fixed an issue with files named node.js on Windows Fix: Fixed an issue with files named node.js on Windows Apr 22, 2022
kevinoid added a commit to kevinoid/eslint-config-kevinoid that referenced this pull request May 7, 2023
To avoid inadvertently running node.js (using Windows Script Host)
instead of node.exe when .js is present in %PATHEXT% (as it is by
default).  The problem is exacerbated by a regression in .cmd shims
generated by npm (npm/cmd-shim#64
npm/cmd-shim#71) and has already caused
problems in CI (actions/setup-node#720).

Continue to export node and node.js from the package for backward
compatibility.  These may be removed in a future version.

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant