So, there are three different ways to refer to directories in Node.js; namely - dot notation (./ and ../), __dirname, and process.cwd(). While all of them might seem to refer to the same thing, they can become a source of confusion and bugs, if they are not understood well. Let's examine how they work.
Create a directory named base with the following tree under it:
[code]
.
├── app.js
└── /one
├── on ...

I have been blogging about Express.js for quite some time now. Early this year, I was contacted by Packt, enquiring me if I'd be interested in writing a book on Express.
A year ago, I had this idea to write a book on Express, which would be titled "Mastering Express.js", and worked out an early-stage table of contents for it. So when Packt contacted me, I told them that I would, in fact, be very interested in writing a book on Express. Sin ...

Express.js comes with a badass HTML pre-processor, Jade, but sometimes you may just want to use the good old HTML files for whatever reason. Is there a way to accomplish this? Oh yes, there is!
The short and quick answer to this requirement is - dump the files in the [obj]public[/obj] directory!
There is a slightly more elaborate but cleaner method, which will help you from cluttering up your [obj]public[/obj] directory with the HTML files - use the [obj]static[/obj] middleware.
Create ...

Is there a way to enable the module loading capability of Node.js in the browser? How wonderful it would be if you could write JavaScript modules the Node.js way and load them in the browser.
There have been many attempts at doing this. Notable among them are RequireJS and Browserify. Both got things done one or the other way, but are unnecessarily complicated and a pain to use.
If you type "browserify" or "requirejs" ...

What in the world could "Scripting a Node.js App" mean?
Well, we are talking about the ability to write scripts for your Node.js apps. Wouldn't it be cool to be able to write independent JS scripts and execute them on the fly, in your app? This post is about that ability.
When I first encountered the Node.js vm (Virtual Machine) module, I thought, "Hmmm, this thing looks like eval(). How different is it from ev ...