angularjs - 浏览器同步 headless 环境错误

标签 angularjs node.js npm browser-sync npm-start

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

$ 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 是默认浏览器

相关问题https://stackoverflow.com/a/42845813/8130472得到答复并建议选择将 C:\Windows\System32 添加到系统变量,但我不知道如何进行。

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

有什么建议吗?或者解决方案?

最佳答案

所以当我继续浏览时,我在这个网页https://gist.github.com/Kenty/9096000/revisions上找到了解决这个问题的线索。这暗示我可以从错误消息中找到打开选项。我决定在我的电脑上搜索 "bs.config.js" ,并在我的 \Template\node_modules\中找到一个名为 default.config.js 的文件browser-sync\lib 文件夹位于我的 Angular 文件夹下,当我搜索该文件时,我终于找到了打开选项,并将打开选项从“local”(这是默认选项)更改为 false(注意,它是不带引号),当我在 git-bash 终端上再次运行 npm start 命令时,它起作用了,并且没有更多错误。

关于angularjs - 浏览器同步 headless 环境错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44432953/

相关文章:

mysql - 如何将 ACL Node js 角色与数据库 MySQL 中的用户连接(sequelize)

npm - 错误: Command failed: cscript. exe//无标志

javascript - 我如何使用 postinstall 编辑 package.json

npm - 如何查看给定 npm 模块的依赖树?

javascript - Angular : circular dependency of specific case

javascript - Rails Angular grunt 代理

javascript - AngularJS - 如果 ng-option 为空,则隐藏 <select> 元素

node.js - 使用node的ejs模板框架处理php文件

javascript - Node 事件发射器

angularjs - 在嵌套的 ng-repeat 指令中使用 ng-model