Gulp - non-loading with a stray environment: livereload.js is not available

I have a problem using gulp-livereload in my wandering environment (generated using puphpet). My computer is Windows Host, and VM is Debian.

I am using this gulpfile file:

 var gulp = require('gulp'), less = require('gulp-less') lr = require('tiny-lr'), livereload = require('gulp-livereload'), server = lr() ; gulp.task('less', function () { gulp.src('assets/less/*.less') .pipe(less()) .pipe(gulp.dest('build/css')) .pipe(livereload(server)) ; }); gulp.task('watch', function() { gulp.watch('assets/less/*.less', ['less']); livereload.listen(35729, function(err){ if(err) return console.log(err); }); }); gulp.task('default', ['watch', 'less']); 

And when the Chrome Extension adds the magic JS file, I get this message:

Failed to load resource: net :: ERR_CONNECTION_TIMED_OUT http ://markup.devhaps5729/livereload.js?ext=Chrome&extver=0.0.5

But in my virtual machine, if I run the following command line, I get it

 wget http://localhost:35729/livereload.js?ext=Chrome&extver=0.0.5 
+6
source share
2 answers

I don’t have enough information to be sure, but I would suggest that your problem is that you are trying to access this page from the host, but the stove port is not redirected (the VM has its own IP address and the firewall may be configured to forward specific ports to the host so that they are "displayed" locally on the host).

Try adding the following line to the Vagrantfile :

 config.vm.network "forwarded_port", guest: 35729, host: 35729 

(For documentation see: https://docs.vagrantup.com/v2/networking/forwarded_ports.html )

Alternatively, if you click directly on the virtual machine (i.e. you have markup.dev mapped to the guest IP address), it might be worth checking that your virtual machine does not have a firewall configured that can block the mail from external access.

+8
source

In my case, port forwarding worked automatically. However, I had to specify the IP address of the virtual machine as the host:

 livereload.listen({ host: '192.168.33.10' }); 

Update : null transfer is also performed:

 livereload.listen({ host: null }); 

I believe the underlying http server behaves differently when passing 'localhost' explicitly .

+2
source

Source: https://habr.com/ru/post/978390/


All Articles