"LiveReload disabled because it could not find its own <SCRIPT> tag" after a handful of saves
Closed this issue · 14 comments
That's what the console says when I load /
. My setup:
budo --live --open index.js
win7x64sp1
nodejs 7.3.0
Um, OK, the first few force-reloads didn't fix this, and now, it somehow fixed itself. Never mind, sorry for the bother...
Er...it's very intermittent. I'll make several changes to a file, and each save triggers a reload OK, and then suddenly a save will cause that error and no further live reloading will happen until I can get the browser to reload the page from scratch.
Sometimes, that "getting the browser to reload the page from scratch" takes up to 6 "shift+clicking the reload icon". Firefox 50.1.0.
Really strange. I'm just adding a character to a string, to test this. The past three runs took 3, then 2, then 5 saves before this issue happened.
Thanks for testing — so basically it's just not very reliable for you on Windows?
Can you try this script to let me know what events are firing for you?
dev.js
require('budo').cli(process.argv.slice(2), {
live: true
}).on('watch', function (ev, file) {
console.log('file changed', file);
}).on('update', function () {
console.log('new bundle');
});
Save it as dev.js
and then, instead of running budo
, use:
node dev.js index.js
When you save the index.js
file it shoould say "new bundle" and when you save a CSS or HTML file in the same directory it should say "file changed" with the path. If the terminal isn't printing those, it means Chokidar (file watching) is the problem. If the terminal is reliably printing that, but the page isn't reloading reliably, it means tiny-lr (LiveReload) is the problem.
I've been planning on overhauling the LiveReload backend at some point (#194) which may alleviate some of this (it works pretty well for me on OSX but I have heard complaints on other platforms).
Thanks for your help! Unfortunately when I do the above, I get the error Cannot find module 'budo'
even though I installed it globally with npm. The budo
command does work on the command line though. I was using it in this context: https://github.com/lhorie/mithril.js/blob/rewrite/docs/installation.md#live-reload-development-environment (which uses the command-line rather than inclusion in a js script)
Ah — for the above script to work you will need to install it locally npm install budo
. You don't need to save it to your package.json as long as you install it in a directory that has a package.json
. The script is just to test to see where the problem is (live reload vs chokidar).
I've made some progress on the live reload backend, you can also test it like this:
npm install mattdesl/budo#feature/livereload-rework -g
OK, making progress, but now budo serves up a page saying,
"Cannot find module 'fsevents'
myproj\node_modules\chokidar\lib"
That fsevents gets a warning really often using npm, but it always says 'optional'. I'm on Windows at this particular moment but IIRC I also get it on Linux Mint. Makes sense now that I look at the warning more closely, since neither are Darwin:
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\ch
okidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@
1.0.17: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"
})
(I got that installing budo, but no other warnings or errors)
This is also true if I revert the install back from the feature branch.
Ok, I've tested the LiveReload branch on my Windows 10 with node 6.9.4 and fixed a couple small issues, seems to be working alright now. Hopefully the latest version will work for you:
npm install mattdesl/budo#feature/livereload-rework -g
(Or, if you are running budo
in a package.json "scripts"
field, make sure to save it locally with --save
or --save-dev
)
That seems to work great, I made about 20 changes, and every one of them worked. Thanks!
(I would close but I guess you want to leave it open until you merge the branch, etc.)
I'm actually having the same issue on MacOSX 10.11.6 (El Capitan), if it can helps.
Using the livereload-rework branch fixes it.
This should be all merged into budo@10. Thanks!