Donate via PayPal –
Donate via Patreon –

Hey gang, in this Node JS tutorial, I’ll talk about different module patterns, and how we can return multiple items from our custom modules, using the module.exports object.

+ Repo –
+ Atom editor –

You can find more front-end development tutorials on CSS, HTML, JavaScript, jQuery, WordPress & more on the channel homepage…


========== JavaScript for Beginners Playlist ==========

============ CSS for Beginners Playlist =============

============== The Net Ninja =====================

For more front-end development tutorials & to black-belt your coding skills, head over to – or

================== Social Links ==================

Twitter – @TheNetNinja –


  1. didn't worked!!! without the stuff.counter it works fine, but when i uses module.exports.counter, it gives an error and says that stuff.counter is not an function.

  2. I am continuously getting this error. Can anyone help me fix this?

    throw err;

    Error: Cannot find module '/.stuff.js'
    at Function.Module._resolveFilename (module.js:527:15)
    at Function.Module._load (module.js:476:23)
    at Module.require (module.js:568:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (E:web devnode.jsabc.js:1:75)
    at Module._compile (module.js:624:30)
    at Object.Module._extensions..js (module.js:635:10)
    at Module.load (module.js:545:32)
    at tryModuleLoad (module.js:508:12)
    at Function.Module._load (module.js:500:3)

  3. If you don't understand this tutorial then i don't know what you will ever understand, this guy is so clear, and straight to the point.Thanks Ninja Guy (Samurai looking guy) |-), Mr i code with a sword next to me lol

  4. app.js
    console.log(stuff.multi(5, 10));

    var multi = function(x, y){
    return `The product of these 2 numbers are ${x * y}`;

    module.exports.multi = multi;

  5. lol dude you could use es6 ()=> arrow functions and add functions vars like module.exports{counter,adder,pi} es6 works perfectly for me …for example let counter=arr=>{`Array length ${arr.length}`} thx for an amazing video….

  6. Hi Ninja san. Thanks for all you effort. Maybe a out of scope question in this lesson. Why does console.log(stuff.adder(stuff.pi, 4)); return "The sum of the two numbers is 7.1419999999999995" ? Odd numbers added to stuff.pi do return the expected value(x.142). Even numbers don't.

  7. Hi
    Just wanted to thank you for this great series of tutorials;

    For those that don't know, they could also reference/export their modules like so:-

    module.exports = {

    Thank you and keep up the good work mate 🙂

  8. For The peeps having trouble with ${a+b}, make sure that the string declaration is wrapped with " ` " and not " ' ". Should be the keystroke below your Esc button.

  9. I hope you never stop making tutorials. Ever. I mean seriously, after all is gone and we're in the middle of an apocalypse selling out our own grandma for a can of beans. I would still like to think you're out there in a cave somewhere with great wifi uploading more tutorials.

  10. Is it a rule that when you export something in a js file that has a certain file name, then to call that you can always use the filename.whatever?


Please enter your comment!
Please enter your name here