ritwickdey / vscode-live-server

Launch a development local Server with live reload feature for static & dynamic pages.
https://ritwickdey.github.io/vscode-live-server
MIT License
5.74k stars 1.26k forks source link

Error: Failed to open browser #104

Closed TuurDutoit closed 6 years ago

TuurDutoit commented 6 years ago

When I start the live server, it starts fine, but it fails to open the browser automatically, with the following error:

Server is started at 5500 but failed to open browser. Try to change the CustomBrowser settings.

The developer tools show the following error:

Error Log to open Browser :  Error: spawn EACCES
    at exports._errnoException (util.js:1050:11)
    at ChildProcess.spawn (internal/child_process.js:319:11)
    at Object.exports.spawn (child_process.js:390:9)
    at module.exports (/home/tuur/.vscode/extensions/ritwickdey.LiveServer-3.2.1/node_modules/opn/index.js:74:26)
    at AppModel.openBrowser (/home/tuur/.vscode/extensions/ritwickdey.LiveServer-3.2.1/out/src/appModel.js:188:13)
    at Golive.LiveServerHelper_1.LiveServerHelper.StartServer (/home/tuur/.vscode/extensions/ritwickdey.LiveServer-3.2.1/out/src/appModel.js:44:26)
    at Timeout.setTimeout (/home/tuur/.vscode/extensions/ritwickdey.LiveServer-3.2.1/out/src/LiveServerHelper.js:15:28)
    at ontimeout (timers.js:386:14)
    at tryOnTimeout (timers.js:250:5)
    at Timer.listOnTimeout (timers.js:214:5)

Digging a little deeper, the culprit seems to be that the xdg-open script in the opn dependency (located for me at /home/tuur/.vscode/extensions/ritwickdey.LiveServer-3.2.1/node_modules/opn/xdg-open) doesn't have the executable flag. When I manually set that flag, the browser is opened as expected.
I looked at the opn source, and even installed it in a separate project, and the flag seems to be set there.

My VS Code info:

Version 1.22.1
Commit 950b8b0d37a9b7061b6f0d291837ccc4015f5ecd
Date 2018-04-06T00:24:49.616Z
Shell 1.7.12
Renderer 58.0.3029.110
Node 7.9.0
Architecture x64

I'm using LiveServer 3.2.1
My machine is running on elementary OS Loki (basically Ubuntu 16.04.3), with Node.js 9.11.1 and NPM 5.6.0

ritwickdey commented 6 years ago

This may be the issue of opn library. You can try following workaround: https://github.com/ritwickdey/vscode-live-server/issues/111#issuecomment-386779921

rjoydip-zz commented 6 years ago

I hope Error: spawn EACCES will be solved when vscode upgrade node version. NPM has been fixed executable permission from npm@5.4.0