Donate via PayPal –
Donate via Patreon –

Yo gang, in this Node JS tutorial, I’ll talk about modules, and how we can use them to split our code up into re-usable, logical sections.

+ 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. what if we want to export more than one function? i mean in the app.js what should i have to write? and suppose i've made two functions inside counter.js and i want to access another function instead of counter ?

  2. What if we have to return multiple functions then how to specify variables for them specificly … I mean if there are two functions in counter.js then how to define differnt for both..

  3. What if there are two functions we want to export then what should be written in module.export and how it can be run separately in app.js after requiring it into a variable?

  4. im trying to export an that I extracted from my main server.js file because I wanted all post stuff to be in a separate file and required back into the main server. js file. I keep getting an app not defined when run it in node. All the examples I'm seeing just simply return a function but when I try to do that, like wrap my code in a function and call it in server.js it can't find app

  5. Why use modules and not just concat everything with gulp or things like that? You would still have your app logically split up and only browser would deal with one file not devs.

  6. Quick question for you, (Thanks for these tutorials! They make perfect sense!) Say I have two functions in one of my modules… function counter(arr), and function foo(). Is it possible for me to export both of those functions? Or can I only export one function per module?

  7. Nice.. Maybe you should mention why you called the "var counter = require….." variable 'counter'. It doesn't work if you call it differently.


Please enter your comment!
Please enter your name here