• Node.js: exports vs module.exports

    What is the difference between exports and module.exports in Node.js? Let's first take a look at what the module object is all about. Create a file named run.js with the following content.

  • Node.js: Publishing an npm package

    How to publish a Node.js module on npm Before you can publish your Node.js module on npm, you have to create one. If you don't know how to create one, read "Node.js: Writing modules". Assuming you ar...

  • Node.js: Writing modules

    How to create Node.js modules A Node.js module is a standalone JavaScript program which exposes an object that can be imported and used by other programs. The object exposed by the module can be of a...

  • Global variables in Node.js

    How to create global variables in Node.js So you are working with a set of Node modules, maybe a framework like Express.js, and suddenly feel the need to make some variables global. How do you make v...

  • Node.js UDP server and client example

    Here is a quick tutorial on setting up a UDP server and client in Node.js. For all things UDP in Node.js, you will need to use the dgram library, so read it up well and good. UDP Server Here is a sim...

  • Node.js: Base64 encoding and decoding

    How to Base64 encode and decode in Node.js Here is how you encodetext to base64 in Node.js: var b = new Buffer('JavaScript'); var s = b.toString('base64'); // SmF2YVNjcmlwdA== And here is how you dec...