2016-03-15 67 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或更低的端口。