If you're manually adding the script to your layout file, the port is fixed (at, for example, 3000), but if that port is in use, Browsersync will pick another port and the website will fail to connect.
We cannot update the layout file every time that the port changes, so it makes sense to configure Browsersync to fail if the port is in use.
Would you consider adding an option that causes a failure if the port is in use?
n/a
Npm [ 3.8.6 ]
[x] linux
[ ] other _(please specify which)_
[x] API
n/a
n/a
V3 has strict mode which will do exactly this, but for now you might consider using the following
var bs = require('browser-sync').create();
bs.init({
server: './app',
port: 9000
}, function (err, bs) {
if (bs.options.get('port') !== 9000) {
console.log('Port 9000 not available');
process.exit(1);
}
});
Great, thanks Shane!
Shall we close this issue?
Most helpful comment
V3 has strict mode which will do exactly this, but for now you might consider using the following