Error with Simple Express Server and Gulp

I'm trying to run a simple Express web server using a gulp task. I only want a static server that displays the index file. I can easily perform this by running a node module, but again, I want to do this in gulp. I plan on expanding this to allow a LiveReload server to be set up.

I have followed many tutorials on setting up LiveReload but they are failing. I'm assuming it has something to do with the versions being used with respect to when the articles are written. But I was hoping maybe somebody had an idea on how to handle this.

I have created a very small Github repo that allows you to play around with what I'm trying to accomplish: fixit

Gulpfile.js:

var gulp = require('gulp');

var EXPRESS_PORT = 4000;
var EXPRESS_ROOT = __dirname;

gulp.task('express', function () {
  var express = require('express');
  var app = express();
  app.use(express.static(EXPRESS_ROOT));
  app.listen(EXPRESS_PORT);
});

*There is an index.html in the same directory as the Gulpfile

And here is the error:

/var/www/clients/client1/web14/sendus-admin/node_modules/express/node_modules/etag/index.js:55
    throw new TypeError('argument entity must be string or Buffer')
          ^
TypeError: argument entity must be string or Buffer
  at etag (/var/www/clients/client1/web14/sendus-admin/node_modules/express/node_modules/etag/index.js:55:11)
  at SendStream.setHeader (/var/www/clients/client1/web14/sendus-admin/node_modules/express/node_modules/send/index.js:724:15)
  at SendStream.send (/var/www/clients/client1/web14/sendus-admin/node_modules/express/node_modules/send/index.js:500:8)
  at onstat (/var/www/clients/client1/web14/sendus-admin/node_modules/express/node_modules/send/index.js:585:10)
  at Object.oncomplete (fs.js:97:15)

I had the same problem and after a week without Gulp and BrowserSync working (the combination giving me the same error), I resorted to more severe options like reinstalling Node.js. In the end, what worked for me was to use nvm to downgrade to Node.js version 10 (I was using 11 before).

nvm install 0.10
nvm use 0.10

Then just updated and used Gulp:

npm update
gulp

Sure hope that helps you too.

I had the same problem with Express.static since a week. Disabling ETAG for Express.static solves this problem for me untill there is a better fix:

app.use(express.static(path.join(__dirname, '/static'), {etag: false}));