0

I have successfully written this code and it executes in bash, but doesn't launch the browser. Any help is appreciated.

Both the commented out code and the uncommented launch in bash fine, but I never get chrome to open my html file. How do get chrome to open? Am I missing something?

Toshiba Laptop@ToshibaLaptop MINGW64 ~/Desktop/Projects/trave-site (master)
$ gulp watch
[14:48:50] Using gulpfile ~\Desktop\Projects\trave-site\gulpfile.js
[14:48:50] Starting 'watch'...
[14:48:50] Finished 'watch' after 26 ms
[Browsersync] Access URLs:
 -----------------------------------
       Local: http://localhost:3000
    External: http://10.0.0.235:3000
 -----------------------------------
          UI: http://localhost:3001
 UI External: http://10.0.0.235:3001
 -----------------------------------
[Browsersync] Serving files from: ./app


//gulp.task('browser-sync', function() {   // this works if uncomented
//    browserSync.init({
//        server: {
//            baseDir: "./"
//        }
//    });
//});

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



    browserSync.init({             // this works as well neither launch chrome
       server : {
           baseDir: "./app",
           index: "index.html"
       } 
   });


});
Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158
  • I think that should open your default browser. You can try explicitly setting thie option: `browser: "google chrome"` as well. – Mark Oct 20 '19 at 22:50
  • I've tried that as well and nothing... I'm at a loss I've searched and seen this answer in many spots and it hasn't worked for me. – user2567123 Oct 21 '19 at 01:53
  • Your code works fine for me. Your `index.html` is in `app/index.html` and the `app` folder is at the same level as your gulpfile.js? – Mark Oct 21 '19 at 02:25
  • Correct, but chrome doesn't load? – user2567123 Oct 21 '19 at 10:06
  • Weird thing, with the gulp.watch task running I can type in the localhost address and get my html to load. If I end the watch task it won't load... I am also unable to access the external address either way. – user2567123 Oct 21 '19 at 21:31
  • Well, you would not typically put the browserSync stuff in a `watch` task - the browserSync.init would fire and start up another browser tab each time one of your watched files changes. Try putting the browserSync.init code into a default task and see if the browser will open. – Mark Oct 21 '19 at 21:40
  • Tried that too. the top task is outside of the watch task, and works just as well., but will not launch chrome. – user2567123 Oct 21 '19 at 22:45

0 Answers0