The following setup works like this:
- I change a file
- gulp tasks kick off that end up changing
/file/to/watch.js
- nodemon restarts my express server
- browserSync.reload() is called
- the browsers reload
Ever since updating to node 8.9.4 (I think that's when it happened), this no longer works. Steps 1-4 still happen just fine. But not step 5. I still see the 'browserSync.reload!!!' getting logged in my console, but the browser never reloads. I've tried stepping through the browserSync source code, but I don't get very far before I'm in functions labeled "native code".
Any ideas how to get my browsers reloading again?
return nodemon({
script: '/path/to/script.js',
watch: '/file/to/watch.js',
env: {
'PORT': 7000
}
}).on('start', function() {
// to avoid nodemon being started multiple times
// thanks @matthisk
if (!started) {
cb();
started = true;
}
console.log('browserSync.reload!!!');
browserSync.reload();
});
UPDATE: I figured out that the problem is that the browser-sync script tag is not being injected. I also found out that if I change the open
option from false
to true
, then it works. I prefer to have that set to false
, though, and it used to work that way. Not sure what changed.