Blog Articles

process.cwd vs __dirname in Node.js

Wirtten on 12/19/2016, by Kevin Chisholm | Comments

Sometimes you want to know where you are. This happens plenty of times in real life, but it also happens in Node.js. If you need to programatically determine the current folder, you may turn to process.cwd() or __dirname. There is a difference between them though. In this article we'll discuss difference between the process.cwd() method and __dirname keyword. To get started, clone the following...

Read more

Using fat arrow functions in your Node module

Wirtten on 12/19/2016, by Kevin Chisholm | Comments

Functions are first-class citizens in JavaScript. This is one of the most popular aspects of the language. It is also one of the most powerful features. When a function is a property of an object, it is also considered a method of that object. Inside of a method, the this keyword provides value. It allows us to access the object to which the method belongs, and its other properties. There is a...

Read more

Sending multiple HTTP responses with Express.js

Wirtten on 11/25/2016, by Kevin Chisholm | Comments

The Express.js framework simplifies the task of creating a Node.js web server. When crafting your response to the user, the send method of the Express response object is a powerful tool. It provides abstraction for sending the response. This includes setting the appropriate content-type header, and then ending the response process. That is a lot, and it is helpful. But what about when you want...

Read more

10 Recommended Resources for learning about Node.js

Wirtten on 11/25/2016, by Kevin Chisholm | Comments

I have found that there are two types of web developers. Those who think Node.js is great, and those who have not realized it yet : - ). To members of the first group, I say: "C'mon back when you realize that Node.js is great". Members of the first group probably realize how overwhelming it can be when learning about Node. There are many web pages that provide information on Node. The quality...

Read more

Concurrency and Other Async Node Patterns

Wirtten on 10/25/2016, by Azat Mardan | Comments

Concurrency and Other Async Node Patterns Most of us learned programming in a synchronous manner and never bothered with asynchronous patterns. Well, you might start learning async now, because asynchronous code is more efficient than synchronous, but to write good async code you need to know at least a few Node patterns. This lesson will cover the concurrency and error handling patterns:...

Read more

Easy HTTP POST testing with the request module

Wirtten on 10/17/2016, by Kevin Chisholm | Comments

GET and POST requests are common in web development. GET is one that you see more often. For example, when you load most web pages, the majority of the requests that comprise the page are GET requests. But sometimes, you need to make a POST request. Testing a GET request is easy. Testing a POST request is not always so simple because the HTTP request body must include any data you send. An...

Read more

10 things I wish I knew about Node when I started

Wirtten on 10/03/2016, by Kevin Chisholm | Comments

Everyone comes to Node from different angles. Some back-end developers decide to dive into JavaScript. Sometimes a front-end developer will choose Node as their first back-end language. Regardless of your path, getting started with Node can sometimes be a challenge. One of the big reasons for this is the context switch. The Node ecosystem is as different as any other. In this article, I have...

Read more

How Node Event Loop REALLY Works: Or Why Most of the Event Loop Diagrams are WRONG

Wirtten on 09/29/2016, by Azat Mardan | Comments

When Bert Belder (one of the early Node core contributors) presented his keynote at Node Interactive Europe 2016 on Event Loop, he started by saying that most of event loops diagrams are WRONG. I'm guilty of using one of them in my talks. :) This is it. In it, event loop is spinning data back at clients like hot-cakes. His diagram is closer to the real stuff. In it, event loop starts, works...

Read more

Introduction to the uglify-js Node.js module

Wirtten on 09/19/2016, by Kevin Chisholm | Comments

Compressing one or more JavaScript files is a common front-end tooling task. Developers often consider this to be part of the front-end build process. Tools such as Grunt and Gulp are often used. This is fine. But is also possible to compress JavaScript files using Node. In this article, I will introduce the uglify-js Node module. This module allows you to compress one or more JavaScript files,...

Read more

Getting started with npm scripts

Wirtten on 09/01/2016, by Kevin Chisholm | Comments

Node.js has been riding the wave of JavaScript's growing ubiquity. As the default package manager for Node.js, npm has seen a parallel rise in popularity. There is good reason for this. npm is well-built, well documented, and makes Node.js development more seamless. It's hard to imagine using Node.js without npm. For Node.js based projects, developers often turn to technologies such as grunt and...

Read more

Pages