Skip to content
This repository was archived by the owner on Apr 22, 2023. It is now read-only.

Modules with relative and absolute path are not the same #7926

Closed
sateffen opened this issue Jul 10, 2014 · 10 comments
Closed

Modules with relative and absolute path are not the same #7926

sateffen opened this issue Jul 10, 2014 · 10 comments

Comments

@sateffen
Copy link

I just started to test my application with verison 0.11.13, and there is a pretty "interesting" bug, that is new:

console.log(require('c:/Users/sateffen/Documents/Projects/nodgine/Tests/ApplicationTest/TestObject.js') == require('./ApplicationTest/TestObject.js'));

will log false.

I tested this with some more files, and every time the required file is not the same, if one side uses the relative path, and the other one the absolute path.

This is new in version 0.11.13, with version 0.10.29 it's not like this. Is this intended?

I'm using windows 8.1 64bit. If you need to know something, let me know.

@jfhbrook
Copy link

Is the require inside Tests ? ie, c:\Users\sateffen\Documents\Projects\nodgine\Tests\some-file.js ?

@sateffen
Copy link
Author

Yes, both requires are in the same file, inside the c:\Users\sateffen\Documents\Projects\nodgine\Tests\Application.js.
I can execute the content of both modules, it's exactly the same.
The content of the TestObject.js (if helpful) is currently (tested some different things):

module.exports = function () { return 'I am a unique test string, woaaaa'; }

@adohe-zz
Copy link

Hi @sateffen I have test your script in both Mac osx 10.9 and Windows 7.1 64bit with Node version 0.11.13 and 0.10.29, but it seems not any problem, the result is always true, even use '===', it is true.
maybe this is a platform issue but not a Node issue.

@sateffen
Copy link
Author

Hmm, I found out, that it looks like an issue with one letter: The c:
Here are 2 images
Node version 0.10
Node Version 0.11
So the problem is the c:\ or C:\

I found out, why my test is failing, it's the path.join().
Node 0.10: require('path').join('C:\\', 'TestObject.js'); = C:\TestObject.js
Node 0.11: require('path').join('C:\\', 'TestObject.js'); = c:\TestObject.js

And this path.join() creates a path, that goes hand in hand with the "bug" in the screenshots. Currently tested with Windows 8.1 64bit, in like an hour i'm at work, there I can test it with Windows 7 64bit.

@adohe-zz
Copy link

Ok, wait for the test results....

@sateffen
Copy link
Author

On windows 7 64 bit it's the same like above.
require('c:\test.js') == require('C:\test.js') is false, in 0.10 and 0.11, and
Node 0.10: require('path').join('C:\\', 'TestObject.js'); = C:\TestObject.js
Node 0.11: require('path').join('C:\\', 'TestObject.js'); = c:\TestObject.js

So this looks like a general problem on windows machines?

@OrangeDog
Copy link

#7031
#7799

@adohe-zz
Copy link

Yeah i think this is the same problem....

@sateffen
Copy link
Author

Yeah, you're right, the problem is mentioned there allready.
I did not find the other bugs, sorry for repost.

I hope this will get fixed, cause it's some kind of odd behavior. My main problem is, that require('c:\test.js') == require('C:\test.js') is false, so the same file is loaded twice. For me it feels "wrong".

But I guess this is known in #7031 so this could be closed as duplicated. Sorry

@jasnell
Copy link
Member

jasnell commented Jun 3, 2015

Closing as a duplicate.

@jasnell jasnell closed this as completed Jun 3, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants