Medium / phantomjs

NPM wrapper for installing phantomjs
Other
1.42k stars 435 forks source link

Can't open local HTML files in Windows (10) #666

Open patrick-wc opened 7 years ago

patrick-wc commented 7 years ago

I'm pretty sure it's a Windows issue. I'm using postcss-uncss but it also happens with uncss and gulp-local-screenshots-for-windows. If I try and reference URLs, everything works fine:

html: [ 
    'http://localhost:3000/index.html', 
    'http://localhost:3000/about.html',
    etc
]

If I try and use:

html: [ 
    './app/*.html'
]

There is no error, but with uncss the output CSS file only contains a html selector and with gulp-local-screenshots-for-windows I just get a white image with "Not Found" output. I've tried file:///c:/path/to/files/*.html ` and every combination of relative path I can think of, including trying to use:

var path = require( 'path' );
var randomPath = 'app/*.html';
var absolutePath = path.resolve(randomPath);

but I just can't get it to work. When I open an HTML file in a browser in Windows, the URL bar returns:

file:///c:/path/to/files/index.html but it seems like phantomjs doesn't like this. If I try and reference just one particular HTML file in this way, I get this error:

c:\path\to\files\node_modules\uncss\node_modules\phridge\lib\Phantom.js:201
    return new Promise(function (resolve, reject) {
           ^
reject@phantomjs://code/start.js:71:70
onPageLoaded
_onPageOpenFinished@phantomjs://platform/webpage.js:286:27
    -----------------------------------------------------------------------
    at c:\path\to\files\node_modules\uncss\node_modules\phridge\lib\Phantom.js:202:24
    at null.Phantom._send (c:\path\to\files\node_modules\uncss\node_modules\phridge\lib\Phantom.js:201:12)
    at null.Page.run (c:\path\to\files\node_modules\uncss\node_modules\phridge\lib\Page.js:60:25)
    at null.Phantom.openPage (c:\path\to\files\node_modules\uncss\node_modules\phridge\lib\Phantom.js:156:17)
    at Object.fromRemote (c:\path\to\files\node_modules\uncss\src\phantom.js:150:36)
    at c:\path\to\files\node_modules\uncss\src\uncss.js:42:28
    at tryCatcher (c:\path\to\files\node_modules\uncss\node_modules\bluebird\js\release\util.js:11:23)
    at MappingPromiseArray._promiseFulfilled (c:\path\to\files\node_modules\uncss\node_modules\bluebird\js\release\map.js:57:38)
    at MappingPromiseArray.PromiseArray._iterate (c:\path\to\files\node_modules\uncss\node_modules\bluebird\js\release\promise_array.js:113:31)
    at MappingPromiseArray.init (c:\path\to\files\node_modules\uncss\node_modules\bluebird\js\release\promise_array.js:77:10)
    at new MappingPromiseArray (c:\path\to\files\node_modules\uncss\node_modules\bluebird\js\release\map.js:25:10)
    at map (c:\path\to\files\node_modules\uncss\node_modules\bluebird\js\release\map.js:139:12)
    at Function.Promise.map (c:\path\to\files\node_modules\uncss\node_modules\bluebird\js\release\map.js:147:12)
    at getHTML (c:\path\to\files\node_modules\uncss\src\uncss.js:40:20)
    at c:\path\to\files\node_modules\uncss\src\uncss.js:239:24
    at tryCatcher (c:\path\to\files\node_modules\uncss\node_modules\bluebird\js\release\util.js:11:23)
    at c:\path\to\files\node_modules\uncss\node_modules\bluebird\js\release\using.js:184:26
    at tryCatcher (c:\path\to\files\node_modules\uncss\node_modules\bluebird\js\release\util.js:11:23)
    at Promise._settlePromiseFromHandler (c:\path\to\files\node_modules\uncss\node_modules\bluebird\js\release\promise.js:491:31)
    at Promise._settlePromise (c:\path\to\files\node_modules\uncss\node_modules\bluebird\js\release\promise.js:548:18)
    at Promise._settlePromise0 (c:\path\to\files\node_modules\uncss\node_modules\bluebird\js\release\promise.js:593:10)
    at Promise._settlePromises (c:\path\to\files\node_modules\uncss\node_modules\bluebird\js\release\promise.js:676:18)
    at Promise._fulfill (c:\path\to\files\node_modules\uncss\node_modules\bluebird\js\release\promise.js:617:18)
    at PromiseArray._resolve (c:\path\to\files\node_modules\uncss\node_modules\bluebird\js\release\promise_array.js:125:19)
    at PromiseArray._promiseFulfilled (c:\path\to\files\node_modules\uncss\node_modules\bluebird\js\release\promise_array.js:143:14)
    at Promise._settlePromise (c:\path\to\files\node_modules\uncss\node_modules\bluebird\js\release\promise.js:553:26)
    at Promise._settlePromise0 (c:\path\to\files\node_modules\uncss\node_modules\bluebird\js\release\promise.js:593:10)
    at Promise._settlePromises (c:\path\to\files\node_modules\uncss\node_modules\bluebird\js\release\promise.js:676:18)