VS Code Live sever not working

Hi, I’m trying to open just a basic html file with the live-server extension in vs code on a Chromebook but it keeps giving me these errors.

console.ts:137 [Extension Host] rejected promise not handled within 1 second: Error: spawn google-chrome ENOENT

console.ts:137 [Extension Host] stack trace: Error: spawn google-chrome ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:269:19)
at onErrorNT (internal/child_process.js:465:16)
at processTicksAndRejections (internal/process/task_queues.js:80:21)

ERR spawn google-chrome ENOENT: Error: spawn google-chrome ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:269:19)
at onErrorNT (internal/child_process.js:465:16)
at processTicksAndRejections (internal/process/task_queues.js:80:21)

When I click the Go Live button as well after I click it it will say port with a circle backslash sign. It does work if I go to the live page my self when I type in this http://127.0.0.1:44161/index.html but I’m wondering why it doesn’t work when I click go live, right click/shortcut command open with live server, or when I type live-server in the command line/terminal.

Seems like it is failing to spawn the process to open the browser automatically.

VS Code > Settings > search for “Live Server” > Live Server>Settings: Custom Browser. If null, try changing it to chrome or firefox (if you have it) and see if that changes anything.

You can also try setting the path manually under “Advance Custom Browser Cmd Line” in the settings.json

chrome://version/ in the address bar should give you the browser path.

Here are my settings.json that I have. I had the custom browser set to chrome and it still didn’t work. For “Advance Custom Browser Cmd Line” what value another than null can I put in for chrome or Firefox to be set as my default browser? did you mean to put chrome://version/ as a value in that setting or did you mean that’s what should be in the browser address bar when I open a file in the live server?
My Chromebook runs a Debian Linux beta, I don’t know though if that has anything to do with why the live server is not running.

Put chrome://version/ in the browser address bar and press enter. It will give you information about the path to Chrome so you can put the full path in the settings file.

It might be related to the platform (Chromebook/Linux) there might be some restrictions. Also, is it Chrome, or Chromium that is used as the browser?

It is chrome that is used as the default browser. Do I type the executable path or the profile path in the settings? I do think it has something to do with restrictions to Linux/Chromebook. Other extensions haven’t worked for me either on this computer and one of the shortcuts (the alt/option up button) has not worked for me.

There is a fork of the Live Server extension which is actively maintained. Looking at the commit history I can see some updates to the code related to opening the browser, so it might be worth a try.

https://marketplace.visualstudio.com/items?itemName=yandeu.five-server


One of the updates is specific to the npm package used for opening the browser (open) (Live Server is using 5.0.3, the fork is using 8.0.8). And looking at the package docs and your error message they might be related (the rejected promise).

open(target, options?)

Returns a promise for the spawned child process. You would normally not need to use this for anything, but it can be useful if you’d like to attach custom event listeners or perform other operations directly on the spawned process.

The five server extension works for me. The server opens on Firefox but not on chrome. I tried to edit the browser settings in Five Server using the JSON file but it does not seem to respond.

Good to hear it works.

Not sure what the correct string is for the option. But looking at the open npm package it might be google-chrome (on Linux).

Still doesn’t work. Do you think because this is still a new extension that it might be a bug? Thanks for your prompt responses and help with this by the way.

I don’t believe the use of VS Code settings has been implemented yet. Look at the docs they show using an .fiveserverrc or fiveserver.config.js

.fiveserverrc

{
  "browser": "chrome"
}

fiveserver.config.js

module.exports = {
  browser: "chrome",
}

Still not sure if the string depends on the OS or not.

You can add this to the fiveserver.config.js file. It will try them all and log out the attempts to the terminal (VS Code > View > Terminal).

module.exports = {
  debugVSCode: true,
  browser: ["google chrome", "google-chrome", "google-chrome-stable", "chrome"],
};

Should output something like this:

Could not open browser "google chrome". Trying "google-chrome" next.
Could not open browser "google-chrome". Trying "google-chrome-stable" next.
Could not open browser "google-chrome-stable". Trying "chrome" next.

If it still doesn’t work, I would suggest opening an issue on the extension repo.

Do I make the fiveserver.config.js file like this or am I doing something wrong here?

Only one module.exports and the config file have to be in the root folder (the one with your index.html), not in node_modules.

Just wanted to double check with you it’s supposed to be like this right? Chrome doesn’t look like it’s able to spawn.

Can you try using the debug, as I showed?

module.exports = {
  debugVSCode: true,
  browser: ["google chrome", "google-chrome", "google-chrome-stable", "chrome"],
};

Sorry I actually did that before but forgot to send it. Did I log it correctly? Still doesn’t seem to work.

OK, so it just errors/crashes the minute it can’t spawn the process and doesn’t proceed to the next name in the array.

Not really sure what to say, one thing you might want to check is the environment variable for Chrome. I think you would normally get that error if you tried running something that didn’t exist, but I’m guessing the lack of, or incorrect, environment variable might do the same (google search for error).

Otherwise, I think maybe you should try opening an issue and hear what the author has to say about it.

1 Like

Thanks for your prompt responses and help with this issue. I think I will open an issue with the author about this problem.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.