Miru crashes on start
luminarious opened this issue · 7 comments
Hey! I Tried the most basic of commands: miru --path public
and got an error:
miru.init.js file created at [public/miru.init.js]
/usr/local/lib/node_modules/miru/index.js:280
opts.targets.forEach(function (target, i) {
^
TypeError: Cannot read property 'forEach' of undefined
at Object.<anonymous> (/usr/local/lib/node_modules/miru/index.js:280:13)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/local/lib/node_modules/miru/cli.js:3:1)
at Module._compile (module.js:570:32)
Node v6.9.1, npm v3.10.8
Got it. But even then something is still wrong:
miru --path public --watch style.css --execute 'stylus source/styles -o public/style.css'
miru.init.js file created at [public/miru.init.js]
/usr/local/lib/node_modules/miru/index.js:280
opts.targets.forEach(function (target, i) {
^
TypeError: opts.targets.forEach is not a function
at Object.<anonymous> (/usr/local/lib/node_modules/miru/index.js:280:14)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/local/lib/node_modules/miru/cli.js:3:1)
at Module._compile (module.js:570:32)
Halåj!
Indeed, there was an issue when only one -w -e cycle is used. Published a fix for version 0.7.6. Also remember to turn on the watch mode for stylus, otherwise the stylus process exits and miru sets up a recovery watcher to re-init the process on *.css changes -- but if you use the --watch flag in stylus, as intended, your dev experience will be much smoother.
miru --path public --watch style.css --execute 'stylus source/styles -w -o public/style.css
Thanks!
Happy to help, and on to the next setback :D
I put the stylus script from your post into a separate npm task: "watch:css": "stylus source/styles --watch --out public/style.css"
miru --path public --execute 'npm run watch:css' --watch app.js --watch style.css
miru.init.js file created at [public/miru.init.js]
exec cmd [n]
exec cmd [p]
events.js:160
throw er; // Unhandled 'error' event
^
Error: spawn n ENOENT
at exports._errnoException (util.js:1026:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
at onErrorNT (internal/child_process.js:359:16)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
at Module.runMain (module.js:606:11)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:509:3
Hmm, you should receive an error like this since you have a mismatching number of --watch
and --execute
commands:
/usr/local/lib/node_modules/miru/index.js:295
if (!t || !s) throw new Error('-w, -e mismatch')
^
Error: -w, -e mismatch
Also since you're running globally remember to update your the globals with the -g
flag.
Ok, I think I understand now. Most of my troubles stemmed from not understanding that there is a 1:1 relationship on watch and execute tasks. Maybe there is some better syntax to set them up as pairs?
Now that I have it running, I really like it and my next step will be to get it running together with browsersync (this will also serve as the local static file server)
Very cool!
I agree the requirement for a 1:1 matching of -w
and -e
isn't obvious. I tried earlier combining them into the same command with a delimiter in-between but it seemed to be more confusing.
Highly recommend you do indeed run your own web server to serve your index.html since the miru server is mainly intended for the init script miru.init.js
to connect to and start receiving events (even though it does serve the contents of the --path
directory as a convenience)