Posted on by & filed under Content - Highlights and Reviews, Programming & Development, Web Development.

Node.js is an open source stack for writing server-side applications in JavaScript. It’s a very handy tool for writing scalable, real-time apps. It can also be used to quickly prototype a piece of code before rewriting it in a traditional server-side framework such as Ruby on Rails. A software stack is only as useful as the number of good 3rd party libraries and tools available to help developers. Node.js is no exception. It offers a powerful package management tool called Node Package Manager (npm) that is akin to RubyGems, but for Node.

With older versions of Node.js, npm had to be installed separately. In newer versions, however, npm comes installed by default with Node.js. To check that npm is installed properly, type:

If the output is a long explanation of the various commands available with npm, the installation is correct. To read a chapter about npm, see Sams Teach Yourself Node.js in 24 Hours

npm has a concept of global vs. local packages. Global packages are usually those packages that install any new commands in the shell or console. Local packages install new libraries in the current working directory that can be used in your Node.js code. To install a package type:

Here, <package-name> is the name of the package such as express. By default, the package is installed locally in the node_modules directory of the current working directory. To install a package globally, add the -g flag:

Uninstalling a package is similarly a straightforward process:

This will uninstall a local package. The global flag can be used to uninstall a global package. That is:

Sometimes it’s necessary to update a package when a newer version is released. This can be done by doing the following:

This will update all packages given in the list to the latest version. The global flag can again be used to specify local vs. global packages.

Now that we know how to install and manage packages, we need to know where to find them! To search for packages, head over to, which is a central listing of all packages available for installation with Node.js.

To learn how to deploy a module to npm, take a look at this section in Node Cookbook by David Mark Clements.

Safari Books Online has the content you need

Check out these Node JS books available from Safari Books Online:

In just 24 sessions of one hour or less, Sams Teach Yourself Node.js in 24 Hours will help you master the Node.js platform and use it to build server-side applications with extraordinary speed and scalability. Using this text’s straightforward, step-by-step approach, you’ll move from basic installation, configuration, and programming all the way through real-time messaging between browser and server, testing and deployment. Every lesson and case-study application builds on what you’ve already learned, giving you a rock-solid foundation for real-world success!
CoffeeScript is a young but popular language that makes web programming fun and more productive. It compiles to JavaScript and unleashes its powerful features while not straying too far from the language. It’s become one of the most popular languages on Github and is being used for both browser and server side programming. CoffeeScript programming with jQuery, Rails, and Node.js will not only teach you the CoffeeScript language but also show you how it’s being used by professional programmers with the latest web technologies.
This book shows you how to transfer your JavaScript skills to server side programming. With simple examples and supporting code, Node Cookbook talks you through various server side scenarios often saving you time, effort, and trouble by demonstrating best practices and showing you how to avoid security faux pas.
Take your web development skills from browser to server with Node—and learn how to write fast, highly scalable network applications on this JavaScript-based platform. With Learning Node, you’ll quickly master Node’s core fundamentals, gain experience with several built-in and contributed modules, and learn the differences and parallels between client- and server-side programming.
Node Web Development gives you an excellent starting point straight into the heart of developing server side web applications with node. You will learn, through practical examples, how to use the HTTP Server and Client objects, the Connect and Express application frameworks, the algorithms for asynchronous execution, and use both SQL and MongoDB databases.

About the author

Shaneeb Kamran is a Computer Engineer from one of the leading universities of Pakistan. His programming journey started at the age of 12 and ever since he has dabbled himself in every new and shiny software technology he could get his hands on. He is currently involved in a startup that is working on cloud computing products.

Tags: global packages, Javascript, local packages, Node Package Manager, Node.js, NPM, Package Management, server side,

Comments are closed.