BROWSER SYNC headless environment ERROR

Esther picture Esther · Jun 8, 2017 · Viewed 12.1k times · Source

So i just started learning Angular 2 and after running the npm install command on git bash and opening my text editor, I was trying to run the npm start command to start the typescript and lite server. Everything went well until this error showed up [1] [BS] Couldn't open browser (if you are using BrowserSync in a headless environment, you might want to set the open option to false) and the browser didn't open. Here's how it looks `

$ npm start

[1] [BS] Access URLs:
[1]  --------------------------------------
[1]        Local: http://localhost:3002
[1]     External: http://172.30.31.239:3002
[1]  --------------------------------------
[1]           UI: http://localhost:3003
[1]  UI External: http://172.30.31.239:3003
[1]  --------------------------------------
[1] [BS] Serving files from: ./
[1] [BS] Watching files...
[1] [BS] Couldn't open browser (if you are using BrowserSync in a headless environment, you might want to set the open option to false)
`  

I'm using a Windows 8 64bit OS and Chrome is the default browser

A related question https://stackoverflow.com/a/42845813/8130472 was answered and suggested the option of adding C:\Windows\System32 to the System Variables but i don't know how to go about it.

Also, on this link, https://forums.bignerdranch.com/t/browser-sync-couldnt-open-browser/10936/4 another suggestion was to add the --browser"chrome.exe"(Windows). That didn't work either.

Any suggestions? Or Solutions?

Answer

Esther picture Esther · Jun 12, 2017

So while I kept browsing, i found a clue to the solution of this problem on this webpage https://gist.github.com/Kenty/9096000/revisions which hinted me of where i could find the open option from the error message. I decided to searched for "bs.config.js" on my pc and i found a file called default.config.js in my \Template\node_modules\browser-sync\lib folder under my angular folder and when i searched through the file, i finally found the open option and changed the open option from "local" (which is the default option) to false (Note, it's without the quotes) and when i ran the npm start command again, on the git-bash terminal It worked and there were no more errors.