Appendix A. Modules in Node.js

 

This appendix covers things you need to know about modules and Node.js to use both effectively in your Grunt builds. Node.js is a platform built on top of the V8 JavaScript engine, the same engine that makes JavaScript in Google Chrome a reality. Grunt, the build tool you use in this book, runs on Node. Node is single threaded, as all JavaScript is.

Node comes with a nice little companion command-line interface (CLI) utility called npm, which is used to fetch and install packages from the node-packaged modules registry. Throughout the book, you’ll learn how to use the npm tool as needed. Let’s install Node.js first, since npm comes bundled with it!

A.1. Installing Node.js

You have a few options for installing Node. If you’re the point-and-click type, then you might want to head over to their website, http://nodejs.org, and click on the big green Install button. Once the binaries are downloaded, unpack them if needed, and then double-click to install them. That’s it.

If you prefer to install things in your terminal, consider nvm, a user-created Node version manager. To install nvm, you can type the following line into your terminal:

curl https://raw.github.com/creationix/nvm/master/install.sh | bash

A.2. The module system

A.3. Exporting functionality

A.4. Regarding packages