我现在尝试从Grunt更改为Gulp,并且需要一个静态服务器(gulp-connect不提供keepalive选项,不知道为什么)
但是每当尝试运行gulp browser-sync任务时我都会遇到此错误:
[gulp] Using gulpfile C:\Users\Fernando\Projects\renovaintra.template\gulpfile.js
[gulp] Starting 'browser-sync'...
[gulp] Finished 'browser-sync' after 2.81 ms
[BS] Server running. Use this URL: http://192.168.1.102:3002
[BS] Serving files from: C:\Users\Fernando\Projects\renovaintra.template/public/
[BS] Watching files...
events.js:72
throw er; // Unhandled 'error' event
^
Error: This socket is closed.
at Socket._write (net.js:637:19)
at doWrite (_stream_writable.js:226:10)
at writeOrBuffer (_stream_writable.js:216:5)
at Socket.Writable.write (_stream_writable.js:183:11)
at Socket.write (net.js:615:40)
at Socket.Writable.end (_stream_writable.js:341:10)
at Socket.end (net.js:396:31)
at Static.gzip (C:\Users\Fernando\Projects\renovaintra.template\node_modules\browser-sync\node_modules\socket.io\lib\static.js:207:14)
at ready (C:\Users\Fernando\Projects\renovaintra.template\node_modules\browser-sync\node_modules\socket.io\lib\static.js:370:14)
at C:\Users\Fernando\Projects\renovaintra.template\node_modules\browser-sync\node_modules\socket.io\lib\static.js:103:9
这是我的一项任务:
__location = './public/';
gulp.task('browser-sync', function() {
browserSync.init([__location + '*.html'], {
server: {
baseDir: __location
}
});
});