BrowserSync Gulp doesn#39;t open in Chrome(BrowserSync Gulp 无法在 Chrome 中打开)
问题描述
我尝试在 Chrome 中使用 BrowserSync 和 Gulp 在本地主机上打开我的网站,但它不起作用.默认情况下,它在 Firefox 中打开,一切正常.但是,当我更改 gulpfile.js 中的参数以在 Chrome 中打开网站时 - 我有以下信息:
I try to open my website on localhost using BrowserSync and Gulp in Chrome, but it doesn't work. Default, it open in Firefox and everything works well. But, when I change params in gulpfile.js to open website in Chrome - I have this information:
[Browsersync] 无法打开浏览器(如果您在无头环境,您可能希望将 open 选项设置为 false)我在 gulpfile.js 中的配置:
[Browsersync] Couldn't open browser (if you are using BrowserSync in a headless environment, you might want to set the open option to false) My config in gulpfile.js:
// browser-sync options
// see: https://www.browsersync.io/docs/options/
var browserSyncOptions = {
browser: "google chrome",
proxy: "localhost",
notify: false
};
我尝试了chrome"、chrome-browser",但没有任何反应.我应该怎么做?注意:我有 Ubuntu 17.04,Chrome 是我的默认浏览器.
I tried "chrome", "chrome-browser", nothing happend. What I should to do? Notice: I have Ubuntu 17.04, Chrome is my default browser.
推荐答案
我认为问题出在您的端口上,尝试将您的代理更改为以下:
I think the issue is with your port, try to change your proxy to below :
var browserSyncOptions = {
browser: "google chrome",
proxy: "localhost:3001",
notify: false
};
并使用此端口在 chrome 中检查您的网站:
and check your website in chrome with this port :
http://localhost:3001
更新:
也尝试在 browserSync 中使用相同的端口:
Also try to use the same port in browserSync :
browserSync({
proxy: 'localhost:3001'
});
这篇关于BrowserSync Gulp 无法在 Chrome 中打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:BrowserSync Gulp 无法在 Chrome 中打开


基础教程推荐
- 我可以在浏览器中与Babel一起使用ES模块,而不捆绑我的代码吗? 2022-01-01
- 如何使用TypeScrip将固定承诺数组中的项设置为可选 2022-01-01
- Vue 3 – <过渡>渲染不能动画的非元素根节点 2022-01-01
- Electron 将 Node.js 和 Chromium 上下文结合起来意味着 2022-01-01
- 如何使用JIT在顺风css中使用布局变体? 2022-01-01
- 直接将值设置为滑块 2022-01-01
- 自定义 XMLHttpRequest.prototype.open 2022-01-01
- Chart.js 在线性图表上拖动点 2022-01-01
- 用于 Twitter 小部件宽度的 HTML/CSS 2022-01-01
- html表格如何通过更改悬停边框来突出显示列? 2022-01-01