問題描述
我嘗試在 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模板網!