NPM

Get started organizing and sharing your Node.js code with the Node.js Package Manager.

Scroll down...

Content

Resources

Comments

NPM stands for Node Package Manager. Here is a quick video that explains NPM from the official NPM website.

What is NPM?

NPM is Node.js's package manager, it handles the organization of all the reusable bundles of code that you will download, create and incorporate into your projects.

NPM ships with Node.js. It will be your interface for downloading, creating, updating, deleting and managing all of your Node.js packages. NPM even updates itself by name with $ npm install -g npm.

When you want to create a new Node.js package you'll use NPM. When you want to download and update packages you'll use NPM. NPM can install global packages and local packages. The versions of these packages are tracked on a project specific basis via a package.json file that closely resembles the function of a Gemfile.

Basically the package.json file is where NPM stores information about the current project. It will manage your packages to make sure compatible versions are installed.

Here is a quick rundown of using NPM:

# Install a package locally
$ npm install some-package

# Update local packages
$ npm update

# Install a package globally
$ npm install -g some-package

# Update a global package
$ npm update -g some-package

# Uninstall a package
$ npm uninstall -g some-package

# Create a new package or project
$ npm init
# ... then follow the instructions ...

NPM is incredibly useful and indispensable to Node.js. Working with Node.js will require you to be familiar with the ins and outs of NPM. Luckily they have very good documentation with clear examples.

Here is the full documentation for NPM.

Popular Node.js Packages

Node.js has more packages than any other platform out there! Here are a few of the most popular ones:

  1. Babel.js Compile ES5 to ES6
  2. Lodash
  3. Request Simplified HTTP requestst client
  4. Moment A lightweight JavaScript date library for parsing, validating, manipulating, and formatting dates
  5. React JS framework powered by Facebook
  6. Mongoose Elegant MongoDB object modeling for Node.js

Here is a link to the most starred NPM packages.

Node.js packages can be small helper libraries or full frameworks. Here are a few of the most popular Node.js frameworks.

Popular Node.js Frameworks

There are countless frameworks out there for Node.js and new ones are always popping up. There are some definite big hitters out there that you most likely have already heard of. Here are a few:

  1. Meteor.js The JavaScript App Platform
  2. Express.js Fast, unopinionated, minimalist web framework for Node.js
  3. MEAN.js Open-Source Full-Stack Solution For MEAN Applications
  4. MEAN.io MEAN is an opinionated full-stack JavaScript framework

Here is a link to even more popular Node.js frameworks.

If you've been around the Node.js or JavaScript community for a while you've probably heard of Meteor.js. You may not have heard of Express.js. Basically, Express.js is a small web framework that gives you the barebones tools to get a web application running. We'll be diving into how to create a small project with Express.js next.

Code Review

Here are the important snippets of code from this lesson.

# Install a package locally
$ npm install some-package

# Update local packages
$ npm update

# Install a package globally
$ npm install -g some-package

# Update a global package
$ npm update -g some-package

# Uninstall a package
$ npm uninstall -g some-package

# Create a new package or project
$ npm init
# ... then follow the instructions ...

Wrapping Up

NPM will quickly become a tool that you use every day when working with Node.js. Now you're ready to create your own projects and packages using NPM. You're also officially able to take advantage of the wide range of useful open source code that the Node.js community has made available on the NPM registry. Share and enjoy!



Sign up to track your progress for free

There are ( ) additional resources for this lesson. Check them out!

  • NPM NPM official website

Sorry, comments aren't active just yet!