How do I install an NPM package

Use npm to install or update required packages, just like bundlers for Rubygems

I love Bundler, it's great at dependency management. I love npm, node packages installation is easy! I have a NodeJS app and would like to specify my apps dependencies and be able to easily install / update them, wherever I provide my app. This is not a library that I publish, but a full-fledged web app.

I know the command but that just seems to overwrite the directory where packages are installed.

I'm used to using Bundler this way:

Installs Rails v3.0.3 and other required gems on the host computer only if they don't already exist

How can I achieve something similar with npm?


As of npm 1.0 (which is what you now get by default if you follow the steps in the README file), "Bundle" is no longer a separate thing - it's just "How it works".


  1. Put a file in the root directory of your project
  2. List your deps in this file

  3. Since you are calling this with no arguments and not in global mode, only all of your deps will be installed locally.

  4. and be happy.

Edit: This only applies to npm versions <1.0

It was pretty difficult to find out, however NPM makes this possible .

You need three components

  1. A subdirectory in your repository (ie)
  2. A file in the directory above that lists dependencies
  3. A file in the directory above that requires your dependencies


Imagine that Express is your only addiction

deps / package.json

Note: Increase the version number every time you change the dependencies

deps / index.js

Now you should be able to install your dependencies using npm. You can even include this part in your deployment process

Then you can access your specific Express version in your app code as follows:

You should read these two articles from the Isaacs blog (author npm). I think they are really good and I think they are saying how to achieve your goal:


I believe link # 1 (item # 11) explains this:

When you use the npm bundle command, npm places all of your dependencies in the node_modules folder in your package. But it doesn't stop there.

If you want to rely on something that is not in the registry, you can. Just do that:

Installation of the npm bundle Installation of the This will install the content of this tarball in the bundle. You can then list it as a dependency and not try to install it when your package is being installed.

This is also handy if you have your own fork and would rather not change the name.

In fact, you can run almost every npm command in the bundle. To see what's inside you can run the npm bundle ls. To remove something, do npm bundle rm thing. Of course, you can install multiple versions and activate the one you want.

It seems to me that the simplest solution is to use a file with its flag (added to npm just last month) set. This allows you to run or get your project's dependencies, but it prevents someone from accidentally publishing your private project.

Here is an example :

Running is installed on the local system if it does not already exist. Running gives an error because of that.

You and your team can use the version tag internally to track dependency changes over time. Every time you change a dependency, you trigger the version. Use to see which version you have installed.

Publish your app with and list the dependencies in your package.json file.

When someone installs your package, they take care of resolving their dependencies.

Package specification:

We use cookies and other tracking technologies to improve your browsing experience on our website, to show you personalized content and targeted ads, to analyze our website traffic, and to understand where our visitors are coming from.

By continuing, you consent to our use of cookies and other tracking technologies and affirm you're at least 16 years old or have consent from a parent or guardian.

You can read details in our Cookie policy and Privacy policy.