BrowserSync Gulp doesn't open in Chrome

ぐ巨炮叔叔 提交于 2019-12-13 02:46:01

问题


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] 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
};

I tried "chrome", "chrome-browser", nothing happend. What I should to do? Notice: I have Ubuntu 17.04, Chrome is my default browser.


回答1:


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
};

and check your website in chrome with this port :

http://localhost:3001

Update :

Also try to use the same port in browserSync :

browserSync({ 
   proxy: 'localhost:3001' 
}); 



回答2:


Try dropping Google from browser sync call... var browserSyncOptions = { browser: "google chrome", proxy: "localhost:3001", notify: false };

So you just have chrome. var browserSyncOptions = { browser: "chrome", proxy: "localhost:3001", notify: false };



来源:https://stackoverflow.com/questions/47430871/browsersync-gulp-doesnt-open-in-chrome

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!