NodeCasts: Free Node.js Screencasts
Episode 3: Modules
Aug 13, 2012 - 7:25 - 13 comments

Modules are the building blocks of Node.js applications. Find out how to use them and how to create your own.

Show Notes
Node.js version used in this episode: v0.8.6 [ DownloadsDocumentation ]


Module Demonstration


var pi = 3.14;

exports.circumference = function(radius) {
  return radius * radius * pi;

exports.area = function(radius) {
  return 2 * radius * pi;


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

var radius = 1;
console.log("Circ. with radius = 1:", circle.circumference(radius));
console.log("Area with radius = 1:", circle.area(radius));
Eugen F, 12 years ago:
Hey man, nice screencasts! When can we expect continued? :)
Brandon Tilley, 12 years ago:
Thanks, Eugen! A definite schedule hasn't shaken out yet, but for now I'm aiming for a minimum of one per week.
AdamBenAron, 12 years ago:
Hey, really great screencasts, I like them much better than others I've seen.

Alex Bezuska, 12 years ago:
Another awesome episode, thanks again!
Prem Pillai, 12 years ago:
Amazing quality! I learned all my Ruby (and Rails) from Railscasts.

This definitely can be a huge impact on the budding Nodejs community. Keep up the great work!
DeannRie, 12 years ago:
Thank you for interesting video.
unknown, 11 years ago:
Fantastic! Looking forward to more of these.
rmyock, 11 years ago:
mohammad baniasad, 10 years ago:
thanks thanks :)
Ali Pour Zahmatkesh, 9 years ago:
That was great. good quality and easy to learn.

also there is a question :

what kind of module definition is better ? define in variable and then export [maybe it make some hoisting problem] or define them directly in export content , or eaven define in module.export ! which one is the best pattern to development ?

skybedy, 9 years ago:
Perfect for me. Thank you very much.
Manish, 9 years ago:
Paul1987, 8 years ago:
Exceptional video. Clear and informative!
Log in to add your comment!