BrowserSync Gulp无法在Chrome中打开 [英] BrowserSync Gulp doesn't open in Chrome
问题描述
我尝试在Chrome中使用BrowserSync和Gulp在localhost上打开我的网站,但是它不起作用.默认情况下,它在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-浏览器",什么也没发生.我该怎么办? 注意:我有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中打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!