node
node copied to clipboard
Incorrect handling of escaped characters in Windows cmd
Version
v23.3.0
Platform
Microsoft Windows NT 10.0.19045.0 x64
Subsystem
No response
What steps will reproduce the bug?
- Install node.js on Windows in the folder with spaces in the name
- The following cmd command should work correctly
D:\> "D:\Program Files\nodejs\node.exe" -v v23.3.0
- But if you escape a space instead of quoting, node will crash with an error
D:\> D:\Program^ Files\nodejs\node.exe -v
How often does it reproduce? Is there a required condition?
Always, no condition
What is the expected behavior? Why is that the expected behavior?
The command will output a version with no errors
What do you see instead?
D:\> D:\Program^ Files\nodejs\node.exe -v
node:internal/modules/cjs/loader:1242
throw err;
^
Error: Cannot find module 'D:\Files\nodejs\node.exe'
at Function._resolveFilename (node:internal/modules/cjs/loader:1239:15)
at Function._load (node:internal/modules/cjs/loader:1064:27)
at TracingChannel.traceSync (node:diagnostics_channel:322:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:218:24)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:170:5)
at node:internal/main/run_main_module:36:49 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
Node.js v23.3.0
Additional information
Note the module path in the error. It looks like the node loses part of the path before the space