2016-03-15 64 views
1

使用BrowserSync作爲我的網站。以下即時重新加載我的CSS的變化,但它在http://localhost:3000/帶有自定義URL的BrowserSync

gulp.task('sass-watch', ['theme-css'], browserSync.reload); 

gulp.task('browser-sync', function() { 
    var files = [ 
    'htdocs/themes/custom/my-theme/dist/*' 
    ]; 
    browserSync.init(files,{ 
    proxy: 'mysite.com' 
    }); 
}); 

我的網站是通過流浪配置打開一個網頁要在mysite.com本地訪問。我怎樣才能讓BrowserSync在這個自定義的URL上工作?

我用盡不過,我得到一個錯誤使用端口80

gulp.task('browser-sync', function() { 
    var files = [ 
    'htdocs/themes/custom/my-theme/dist/*' 
    ]; 
    browserSync.init(files,{ 
    open: 'external', 
    host: 'mysite.com', 
    proxy: 'mysite.com', 
    port: 80 
    }); 
}); 

我的VM如下:如果我使用的3000的默認端口,然後在頁面加載,但我

events.js:141 
     throw er; // Unhandled 'error' event 
    ^

Error: listen EACCES 0.0.0.0:80 
    at Object.exports._errnoException (util.js:874:11) 
    at exports._exceptionWithHostPort (util.js:897:20) 
    at Server._listen2 (net.js:1221:19) 
    at listen (net.js:1270:10) 
    at Server.listen (net.js:1366:5) 
    at module.exports.plugin (/path-to-my-site/node_modules/browser-sync/lib/server/index.js:24:25) 
    at Object.module.exports.startServer [as fn] (/path-to-my-site/node_modules/browser-sync/lib/async.js:236:52) 
    at /path-to-my-site/node_modules/browser-sync/lib/browser-sync.js:149:14 
    at iterate (/path-to-my-site/node_modules/browser-sync/node_modules/async-each-series/index.js:8:5) 
    at /path-to-my-site/node_modules/browser-sync/node_modules/async-each-series/index.js:16:16 

得到錯誤連接被拒絕。

ERR_CONNECTION_REFUSED

+0

你沒有得到這個加載mysite.com沒有端口? – Justin

回答

0

你的第一次嘗試是正確的,當然這樣你會得到browserSync,以滿足您的http://localhost:3000應用程序,這是默認的。

第二個沒有什麼不對,除了您正試圖分配給browserSync的地址已被vagrant使用。

所以,如果你想browserSync在mysite.com上,你應該配置vagrant採取別的。

如果這樣做,那麼腳本變爲:

gulp.task('browser-sync', function() { 
    var files = [ 
    'htdocs/themes/custom/my-theme/dist/*' 
    ]; 
    browserSync.init(files,{ 
    open: 'external', 
    host: 'mysite.com', 
    proxy: 'mylaravel.com', 
    port: 80 
    }); 
}); 
0

您試圖啓動節點作爲非root用戶。 Linux默認只允許root綁定到1024或更低的端口。