Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAKE IT MODULAR - Verify Error #500

Open
jmz527 opened this issue Jan 28, 2017 · 7 comments
Open

MAKE IT MODULAR - Verify Error #500

jmz527 opened this issue Jan 28, 2017 · 7 comments

Comments

@jmz527
Copy link

jmz527 commented Jan 28, 2017

I'm getting an error when verifying the "Make It Modular" exercise. One of the processors seems to be missing a call function.

Here's my "make_it_modular.js" file:

var my_module = require('./my_module');

my_module(process.argv[2], process.argv[3], function(err, arg) {
	if (err) {
		console.log(err)
	} else {
		console.log(arg);
	}
});

Here's the "my_module.js" file:

var fs = require('fs');
var path = require('path');

module.exports = function(dirName, fileExt, callback) {

	fs.readdir(dirName, function (err, list) {

		if (err) return callback(err);

		list.forEach(function (file) {  
			if (path.extname(file) === '.' + fileExt)
			return callback(file);
		})
	})
}

And here's the output when I run learnyounode verify make_it_modular.js:

# LEARN YOU THE NODE.JS FOR MUCH WIN!

## MAKE IT MODULAR (Exercise 6 of 13)


Your submission results compared to the expected:

                 ACTUAL                                 EXPECTED
────────────────────────────────────────────────────────────────────────────────

   "CHANGELOG.md"                      ==    "CHANGELOG.md"
   "LICENCE.md"                        ==    "LICENCE.md"
   "README.md"                         ==    "README.md"
   ""                                  ==    ""

────────────────────────────────────────────────────────────────────────────────

 ✓

 Submission results match expected

 ✓

 Additional module file exports a single function

 ✓

 Additional module file exports a function that takes 3 arguments

 ✓

 Additional module file handles errors properly

 ✓

 Additional module file handles callback argument

/usr/local/lib/node_modules/learnyounode/node_modules/workshopper-exercise/exercise.js:188
    processors[i].call(self, mode, function (err, pass) {
                 ^

TypeError: Cannot read property 'call' of undefined
    at next (/usr/local/lib/node_modules/learnyounode/node_modules/workshopper-exercise/exercise.js:188:18)
    at /usr/local/lib/node_modules/learnyounode/node_modules/workshopper-exercise/exercise.js:195:7
    at callback (/usr/local/lib/node_modules/learnyounode/exercises/make_it_modular/verify.js:26:15)
    at modFileError (/usr/local/lib/node_modules/learnyounode/exercises/make_it_modular/verify.js:31:5)
    at /usr/local/lib/node_modules/learnyounode/exercises/make_it_modular/verify.js:118:18
    at /Users/jamesrutledge/Desktop/nodeschool/learnyounode/my_module.js:12:11
    at Array.forEach (native)
    at /Users/jamesrutledge/Desktop/nodeschool/learnyounode/my_module.js:10:8
    at FSReqWrap.oncomplete (fs.js:123:15)
@hanhdt
Copy link

hanhdt commented Feb 9, 2017

+1

1 similar comment
@igor-klymenok
Copy link

+1

@itsjtwright
Copy link

itsjtwright commented Mar 1, 2017

So your running a for loop on the wrong side of the code. You need the arg you return to be an array and use the forEach loop on the other side. Does that make sense?

Only one thing can be returned and you are trying to return something for every item in the array.

@dmwelch
Copy link

dmwelch commented Mar 24, 2017

Would be helpful if the verify would provide a hint instead of this cryptic error 🙏

@jmz527
Copy link
Author

jmz527 commented Apr 7, 2017

Yup, that makes sense. Don't put your callback function within a loop - the module should only make one callback. I got rid of that loop, added a filter to my module file, a console log loop to my main file, and I got it up & working.

@jmz527
Copy link
Author

jmz527 commented Apr 7, 2017

Here's the part of the directions that tripped me up:

You must write a module file to do most of the work.

If it's too much trouble to work in a human-friendly error, then maybe just revise the lesson a bit or add in an explicit warning.

Thanks for the great workshop!

@AnshulMalik
Copy link
Contributor

As far as I can see, the problem statement tells you that you need to pass an array to callback and call the callback exactly pass.

How can we make it more friendly?

Feel free to open a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants