azat-co / expressworks

Learn Express.js from the author of one of the best books on Express.js—Pro Express.js— with this workshop that will teach you basics of Express.js.
MIT License
709 stars 220 forks source link

Verification failed with an error for all the exercises #89

Closed aclbros closed 8 years ago

aclbros commented 8 years ago

This is the error output:

$ expressworks verify program.js                                                                                                    

?exercises.HELLO WORLD!.compare.title || common.exercise.compare.title || compare.title?

/home/ubuntu/.nvm/v0.11.14/lib/node_modules/expressworks/node_modules/workshopper-exercise/comparestdout.js:19
  return new Array(sz + 1).join(ch)
         ^
RangeError: Invalid array length
    at repeat (/home/ubuntu/.nvm/v0.11.14/lib/node_modules/expressworks/node_modules/workshopper-exercise/comparestdout.js:19:10)
    at center (/home/ubuntu/.nvm/v0.11.14/lib/node_modules/expressworks/node_modules/workshopper-exercise/comparestdout.js:25:13)
    at Exercise.transform (/home/ubuntu/.nvm/v0.11.14/lib/node_modules/expressworks/node_modules/workshopper-exercise/comparestdout.js:57:40)
    at Transform._read (/home/ubuntu/.nvm/v0.11.14/lib/node_modules/expressworks/node_modules/workshopper-exercise/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:184:10)
    at Transform._write (/home/ubuntu/.nvm/v0.11.14/lib/node_modules/expressworks/node_modules/workshopper-exercise/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:172:12)
    at doWrite (/home/ubuntu/.nvm/v0.11.14/lib/node_modules/expressworks/node_modules/workshopper-exercise/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:237:10)
    at writeOrBuffer (/home/ubuntu/.nvm/v0.11.14/lib/node_modules/expressworks/node_modules/workshopper-exercise/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:227:5)
    at Transform.Writable.write (/home/ubuntu/.nvm/v0.11.14/lib/node_modules/expressworks/node_modules/workshopper-exercise/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:194:11)
    at Stream.ondata (stream.js:51:26)
    at Stream.emit (events.js:107:17)

Thanks!

trevorwhitney commented 8 years ago

I am seeing the same problem, using the following code as my solution:

var express = require('express');
var app = express();
app.get('/home', function(req, res) {
  res.send('Hello World!')
});
app.listen(process.argv[2]);

I can run this file with node app.js 3000 and verify a curl to localhost:3000/home works.

azat-co commented 8 years ago

@trevorwhitney @aclbros compare versions of node and express. I have no idea why it's failing for you.

jtiple15 commented 8 years ago

On 'npm/node_modules/expressworks/node_modules/workshopper-exercise/comparestdout.js' (line 23) there seems to be an error with the text formatting calculations. For a quick fix you can return s instead of doing the calculations.

function center (s, sz) { // var sps = Math.round((sz - vw.width(s, true)) / 2) // , sp = repeat(' ', sps) // return sp + s + sp + (sp.length != sps ? ' ' : '') return s; }

Could not find the real cause of the issue though...

aclbros commented 8 years ago

@jtiple15 workaround is working for me. Thanks!

trevorwhitney commented 8 years ago

@azat-co Upgrading the workshopper-excercise version fixed the problem for me, I created a PR: https://github.com/azat-co/expressworks/pull/92