-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
Closed
Labels
moduleIssues and PRs related to the module subsystem.Issues and PRs related to the module subsystem.pathIssues and PRs related to the path subsystem.Issues and PRs related to the path subsystem.windowsIssues and PRs related to the Windows platform.Issues and PRs related to the Windows platform.
Description
- Version: 6.0.0
- Platform: Windows 7 x64
- Subsystem: path, module, process
When cmd.exe is run via a shortcut that has a lowercase drive letter in its 'Start in' field (e.g. d:\dev
) and Node is run from this cmd instance, Node's builtin functions behave in an unexpected way. Some of them return the drive letter in upper case (D:\dev\foo
) whereas the other in lower (d:\dev\foo
).
test.js:
var exprs = ['__dirname', '__filename', 'require.resolve("./test")',
'require("path").resolve("test.js")', 'process.cwd()'];
for (var expr of exprs) {
console.log(expr, eval(expr));
}
In cmd:
d:\dev\foo>node test
__dirname D:\dev\foo
__filename D:\dev\foo\test.js
require.resolve("./test") D:\dev\foo\test.js
require("path").resolve("test.js") d:\dev\foo\test.js
process.cwd() d:\dev\foo
If I change the case of the drive letter in the "Start in" field of the shortcut for cmd, everything becomes consistent.
D:\dev\foo>node test
__dirname D:\dev\foo
__filename D:\dev\foo\test.js
require.resolve("./test") D:\dev\foo\test.js
require("path").resolve("test.js") D:\dev\foo\test.js
process.cwd() D:\dev\foo
This leads to issues like webpack/webpack#2362.
So what can be done about it?
- It'd be great if Node always used upper case.
- Also now Node resolves
d:\test.js
andD:\test.js
as two different modules. Should it stay like this?
d:\dev\foo>echo console.log('load')>bar.js
d:\dev\foo>node
> require('d:\\dev\\foo\\bar.js')
load
{}
> require('d:\\dev\\foo\\bar.js')
{}
> require('D:\\dev\\foo\\bar.js')
load
{}
uMaxmaxmaximus, sindresorhus, Daniel15, MarkPieszak and djpereira
Metadata
Metadata
Assignees
Labels
moduleIssues and PRs related to the module subsystem.Issues and PRs related to the module subsystem.pathIssues and PRs related to the path subsystem.Issues and PRs related to the path subsystem.windowsIssues and PRs related to the Windows platform.Issues and PRs related to the Windows platform.