我尝试在 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 中打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
Browserify,Babel 6,Gulp - 传播运算符上的意外令牌Browserify, Babel 6, Gulp - Unexpected token on spread operator(Browserify,Babel 6,Gulp - 传播运算符上的意外令牌)
是否可以将标志传递给 Gulp 以使其以不同的方式Is it possible to pass a flag to Gulp to have it run tasks in different ways?(是否可以将标志传递给 Gulp 以使其以不同的方式运行任务
为什么我们需要在全局和本地安装 gulp?Why do we need to install gulp globally and locally?(为什么我们需要在全局和本地安装 gulp?)
如何一个接一个地依次运行 Gulp 任务How to run Gulp tasks sequentially one after the other(如何一个接一个地依次运行 Gulp 任务)
由于 MIME 类型而未加载样式表Stylesheet not loaded because of MIME-type(由于 MIME 类型而未加载样式表)
打开 Javascript 文件时 Visual Studio 2015 崩溃Visual Studio 2015 crashes when opening Javascript files(打开 Javascript 文件时 Visual Studio 2015 崩溃)