SHARE

Donate via PayPal – https://www.paypal.me/thenetninja
Donate via Patreon – https://www.patreon.com/thenetninja

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.

—– COURSE LINKS:
+ Repo – https://github.com/iamshaunjp/node-js-playlist
+ Atom editor – https://atom.io/

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

SUBSCRIBE TO CHANNEL – https://www.youtube.com/channel/UCW5YeuERMmlnqo4oq8vwUpg?sub_confirmation=1

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

https://www.youtube.com/playlist?list=PL4cUxeGkcC9i9Ae2D9Ee1RvylH38dKuET

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

https://www.youtube.com/playlist?list=PL4cUxeGkcC9gQeDH6xYhmO-db2mhoTSrT

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

For more front-end development tutorials & to black-belt your coding skills, head over to – https://www.youtube.com/channel/UCW5YeuERMmlnqo4oq8vwUpg or http://thenetninja.co.uk

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

Twitter – @TheNetNinja – https://twitter.com/thenetninjauk

39 COMMENTS

  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 app.post 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 app.post 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.

LEAVE A REPLY

Please enter your comment!
Please enter your name here