gulp connect not opening browser

6k Views Asked by At

I tried setting up the least possible setup for gulp-connect. It shows the following in the terminal window: Server started http://localhost:8080. However it doesn't start Chrome as expected and seen in this video.

var gulp = require('gulp'),
    connect = require('gulp-connect');

var outputDir = "wwwroot";

gulp.task('connect', function() {

 connect.server({
    root: [outputDir],
    open: {browser: 'Google Chrome'}
})});
3

There are 3 best solutions below

2
On

I did some research and didn't found any options for open in gulp-connect. So I'm going to assume that he used an older version of the module witch supported that feature.

Option 1:

To solve your problem you can use gulp-connect-multi, a forked version of gulp-connect witch includes browser opening functionality.

Option 2:

If you still want to use gulp-connect I recommend using a module called gulp-open (or even just open) that opens files and urls in the browser.

Option 3:

Search for more or create you own.

Best of Luck.

0
On

To connect to my browser sync, I navigate to my gulp folder in cmd (the one that has node-mudules, in your project folder) and just type in "Gulp". It automatically opens my project in the browser. Hope this helps.

0
On

I have faced the same issue with gulp-connect. Then I have fixed this issue by installing another package named gulp-connect-multi

npm install --save-dev gulp-connect-multi

var connect = require("gulp-connect-multi")();

gulp.task('html', function () {
    gulp.src(config.paths.html).pipe(gulp.dest(config.paths.dist)).pipe(connect.reload());

});

Hope this helps