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

Incorrect module path resolving with NODE_PATH in Windows #2443

Closed
tamtakoe opened this issue Aug 19, 2015 · 8 comments
Closed

Incorrect module path resolving with NODE_PATH in Windows #2443

tamtakoe opened this issue Aug 19, 2015 · 8 comments
Labels
module Issues and PRs related to the module subsystem. windows Issues and PRs related to the Windows platform.

Comments

@tamtakoe
Copy link

Windows 8.1, io.js 3.0.0

test
|- lib
   |- module.js
|- index.js

NODE_PATH = D:\Projects\test

index.js:

console.log(require.resolve('./lib/module'));
console.log(require.resolve('lib/module'));

So I get different paths:

d:\Projects\test\lib\module.js
D:\Projects\test\lib\module.js

if NODE_PATH = d:\Projects\test (lowercased disk letter) all is ok:

d:\Projects\test\lib\module.js
d:\Projects\test\lib\module.js
@ChALkeR ChALkeR added the windows Issues and PRs related to the Windows platform. label Aug 19, 2015
@mscdex mscdex added the module Issues and PRs related to the module subsystem. label Aug 19, 2015
@seishun
Copy link
Contributor

seishun commented Aug 19, 2015

sigh I thought we got rid of lowercasing drive letters.

@seishun
Copy link
Contributor

seishun commented Oct 15, 2015

I'm unable to reproduce this issue on Node.js v4.2.1. Can you?

@Jokero
Copy link

Jokero commented Jan 28, 2016

@seishun Problem can be reproduced. I do it on nodejs 5.5.0.

D:\Programming\test>node

> process.env.NODE_PATH
'd:\\Programming\\test'

And result:

D:\Programming\test>node index.js

D:\Programming\test\lib\module.js
d:\Programming\test\lib\module.js

@seishun
Copy link
Contributor

seishun commented Jan 29, 2016

I'm not sure if it's a bug. It uses the NODE_PATH variable when you call require.resolve('lib/module') and uses it as-is without changing cases.

@Jokero
Copy link

Jokero commented Jan 29, 2016

Resolved with and without NODE_PATH paths must be the same. It's expected behaviour

@seishun
Copy link
Contributor

seishun commented Jan 29, 2016

I disagree. The paths definitely don't generally have to be the same, since NODE_PATH could point to a different directory and resolve to a different file.

Consider a more obvious example: let's say NODE_PATH involves symlinks. In that case, one would expect require.resolve to return the path that was actually followed, rather than the real path. Letter casing is similar to symlinks in the sense that different paths point to the same physical file.

cc @nodejs/collaborators other opinions?

@mcollina
Copy link
Member

mcollina commented Feb 3, 2016

Apart from different strings, what problems does this cause?

It's not generically wrong or right. Also, it is not expected: you can have the same issue on OS X.

@seishun
Copy link
Contributor

seishun commented Mar 30, 2016

Proposing to close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module Issues and PRs related to the module subsystem. windows Issues and PRs related to the Windows platform.
Projects
None yet
Development

No branches or pull requests

6 participants