3

The title pretty much says it all. I'm on Windows 10, and I have a node app that I start with npm start. (I know almost nothing about node.js.) The app runs on gulp.js. I need the app to open in Firefox, even though Chrome is my default browser. How can I do this? Here's the code that opens the app now; the docs don't allude to there being such an option for the open parameter:

gulp.task('webserver', function() { gulp.src('./app') .pipe(webserver({ livereload: true, open: true, defaultFile: 'index.html', port: serverPort })); });

4
  • This really depends on what npm start does ... what does it do? Commented Jun 2, 2016 at 16:37
  • As you are new, I'll take the liberty of suggesting looking at a build tool such as gulp. It has a module that can do this for you github.com/stevelacy/gulp-open Commented Jun 2, 2016 at 16:38
  • @Aaron, great suggestion... this app is already running on gulp. Can you help with the syntax? Here's what's in there now; how do I add the browser? gulp.task('webserver', function() { gulp.src('./app') .pipe(webserver({ livereload: true, open: true, port: serverPort })); }); Commented Jun 2, 2016 at 16:46
  • Edit your question and I can give you an answer :) Commented Jun 2, 2016 at 16:47

1 Answer 1

1

Install gulp-open by typing the following in to your console

npm install gulp-open --save

Add the following to the top of your gulpfile.js

var open = require('gulp-open');

Add the following to the end of your gulpfile.js

gulp.task('browser', function(){
  var options = {
    uri: 'localhost:<enter the port you are using here>',
    app: 'firefox'
  };
  gulp.src(__filename)
  .pipe(open(options));
});

Add 'browser' to your gulp default. This is what actually opens the browser at the port you are running your app on

gulp.task('default', ['webserver', 'browser']);

in console type gulp

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.