浏览器同步无头环境错误 [英] BROWSER SYNC headless environment ERROR

查看:70
本文介绍了浏览器同步无头环境错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我刚开始学习Angular 2,并在git bash上运行 npm install 命令并打开我的文本编辑器后,我试图运行 npm start 命令来启动打字稿和精简版服务器.一切顺利,直到出现此错误为止 [1] [BS]无法打开浏览器(如果您在无头环境中使用BrowserSync,则可能要将open选项设置为false),并且浏览器未打开.这是它的样子`

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)
`  

我正在使用Windows 8 64位操作系统,而Chrome是默认的浏览器

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

回答了一个相关问题 https://stackoverflow.com/a/42845813/8130472 并建议选择添加C:\ Windows \ System32到系统变量,但我不知道如何去做.

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.

此外,在此链接上, https://forums.bignerdranch.com/t/browser-sync-couldnt-open-browser/10936/4 另一个建议是添加-浏览器"chrome.exe"(Windows).那也不起作用.

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?

推荐答案

因此,当我继续浏览时,我在此网页,然后在我的 \ Template \ node_modules \中找到了一个名为 default.config.js 的文件在我的角度文件夹下的browser-sync \ lib 文件夹中,当我搜索该文件时,我终于找到了打开选项,并将打开选项从本地"(这是默认选项)更改为false(注意,没有引号),当我再次运行 npm start 命令时,在git-bash终端上它起作用了,没有更多错误了.

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.

这篇关于浏览器同步无头环境错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆