0

I would like to run app.js & gulp watch in a single command, however when I run npm run watch, the terminal stop on listen to port 3000, my gulp watch are not executed.

Below are my files:

packaga.json

"scripts": {
    "watch": "node app.js & gulp watch"
  }

app.js

var express = require('express');
var app = express();
app.use(express.static(__dirname + '/build'));
app.listen(3000);
console.log('listen to port 3000');

gulpfile.js

gulp.task('watch', function(){
  gulp.watch('./src/*.scss', gulp.series(['styles', 'css'])); 
})

1 Answer 1

1

"node app.js && gulp watch": This runs the express server, then the gulp command. As long as your server is running the gulp won't be executed I guess. Maybe take a look at this page: Starting an express server from within gulp

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

3 Comments

same, not sure if it due to node version v10.20?
I think that's somehow expected behavior, regardless of which nodejs version you're using. What I mean here is that this won't work on a single terminal: the node process would start listening, and the next command won't be launched until this one has stopped. Express would often require specific packages and that might be the case for Gulp.
ok, thanks for the link, it help. I put the express in the gulp watch function and it works.

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.