Inside NPM: Building and sharing JavaScript packages

The default package manager for Node.js, NPM enables you to install, publish, manage, and distribute JavaScript code easily

Become An Insider

Sign up now and get FREE access to hundreds of Insider articles, guides, reviews, interviews, blogs, and other premium content. Learn more.

The Node Package Manager, NPM, has become a powerful and important tool, supporting many different JavaScript frameworks -- including JQuery, AngularJS, and React JS. If you’re building JavaScript modules and want to share them with the world, NPM is the tool to use.

With a public registry for your code, NPM makes it easy to share code and ensure users can get updates quickly. With small NPM packages, the result is another set of tools for building modular code that’s simple to reuse across your applications, both server-side and client-side.

The NPM registry is a database of modules, showing not only what packages are available, but also how they’re related. When you download a module -- the Express Node.js MVC framework, for instance -- you automatically download the dependencies, so you’re ready to go as soon as all the files you need are installed on your development system.

Roll your own package

Building an NPM package is a relatively simple process since you use the tooling built into NPM itself. Start with NPM’s init command to build the package.json file for your application. You’ll need a name, a version number, and a main .js file. It’s also a good idea to add a name and a contact email address for support.

To continue reading this article register now