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

Already on GitHub? Sign in to your account

Windows Absolute require() #11165

Closed
hexid opened this Issue Mar 24, 2013 · 4 comments

Comments

Projects
None yet
3 participants
Contributor

hexid commented Mar 24, 2013

When trying to require() a script under Windows, I am not able to use an absolute path with drive letters (ex: C:/dev/include.js), while /dev/include.js will work fine.

The only problem with dropping the drive letter is that this is still only relative to the drive of the pwd. So, if I am working on my D drive, I won't be able to access any of the scripts located on the C drive.

Working: require('/dev/include.js');
Not Working: require('C:/dev/include.js');

I'm under the impression that all directories must use forward slashes, by the discussion on #10361.

@hexid hexid referenced this issue in casperjs/casperjs Mar 24, 2013

Closed

Windows require() native modules #429

djgoku commented Mar 24, 2013

Reading this: https://github.com/ariya/phantomjs/wiki/API-Reference-FileSystem

Have you tried this: c:\dev\include.js ?

On Mar 24, 2013, at 3:01 PM, Nick Currier notifications@github.com wrote:

When trying to require() a script under Windows, I am not able to use an absolute path with drive letters (ex: C:/dev/include.js), while /dev/include.js will work fine.

The only problem with dropping the drive letter is that this is still only relative to the drive of the pwd. So, if I am working on my D drive, I won't be able to access any of the scripts located on the C drive.

Working: require('/dev/include.js');
Not Working: require('C:/dev/include.js');

I'm under the impression that all directories must use forward slashes, by the discussion on #10361.


Reply to this email directly or view it on GitHub.

Contributor

hexid commented Mar 24, 2013

Here is the output that I am getting, both with and without escaping the backslashes, and without a drive letter.

C:\>phantomjs
phantomjs> require("C:\dev\include.js");
Cannot find module 'C:devinclude.js'
phantomjs> require("C:\\\\dev\\\\include.js");
Cannot find module 'C:\dev\include.js'
phantomjs> require("\\\\dev\\\\include.js");
Cannot find module '\dev\include.js'
phantomjs> require("/dev/include.js");
{
   "parseArgs": "[Function]",
   "userAgent": " ... "
}
Collaborator

Vitallium commented Mar 24, 2013

Well, it seems that loading modules using an absolute path on Windows is not implemented at all.

For devs: problem at line 220. It works only on Linux, not Windows.

@Vitallium Vitallium was assigned Mar 25, 2013

@Vitallium Vitallium added a commit that referenced this issue Mar 26, 2013

@Vitallium @ariya Vitallium + ariya Fix loading modules from an absolute path on Windows.
Don't check the module path using Linux-style path checking.

Issue #11165: #11165
9ca45ed
Collaborator

Vitallium commented Mar 26, 2013

Fixed. 9ca45ed

@Vitallium Vitallium closed this Mar 30, 2013

@Vitallium Vitallium added a commit that referenced this issue Apr 14, 2013

@Vitallium @ariya Vitallium + ariya Fix loading modules from an absolute path on Windows.
Don't check the module path using Linux-style path checking.

Issue #11165: #11165
e5c456b

@Vitallium Vitallium added a commit to Vitallium/phantomjs that referenced this issue May 28, 2013

@Vitallium Vitallium Fix loading modules from an absolute path on Windows.
Don't check the module path using Linux-style path checking.

Issue #11165: ariya#11165
c4782ff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment