How to Use 'npm install' Command Line Interface

Install node modules / npm packages

Learn how to use terminal / command prompt to install npm packages with a quick one-line command. Read our guide to learn how to install npm, and start using powerful codebases in just seconds with the npm CLI.

npm install [ ...]

aliases: add, i, in, ins, inst, insta, instal, isnt, isnta, isntal, isntall

As an example of a single install, you can run the command "npm install react" to install facebook/react. You can always specify a package you want by including its name after the install action from the npm package. However, you can also omit the package name if you would like to install from a package.json file, to setup multiple node modules at once.

Description

This command installs a package and any packages that it depends on. If the package has a package-lock, npm shrinkwrap, or yarn lock file, the installation of dependencies will be driven by that, respecting the following order of precedence:

  1. npm-shrinkwrap.json
  2. package-lock.json
  3. yarn.lock

A package can be one of the following:

Commands

npm install (in a package directory, no arguments):

Install the dependencies to the local node_modules folder. In global mode (with -g or --global), it installs the current package context as a global package.

By default, npm install will install all modules listed as dependencies in package.json. Use the --production flag to avoid installing modules listed in devDependencies when the NODE_ENV environment variable is set to production.

npm install

npm install <folder>:

Install the dependencies of a package in a specified folder. If the folder is inside your project root, dependencies may be hoisted to the top-level node_modules folder. Otherwise, npm creates a symlink to the folder.

npm install ../../other-package --install-links
npm install ./sub-package

npm install <tarball file>:

Install a package from a tarball file on the filesystem.

npm install ./package.tgz

npm install <tarball url>:

Fetch the tarball URL and then install it. The URL must start with "http://" or "https://".

npm install https://github.com/indexzero/forever/tarball/v0.5.6

npm install [<@scope>/]<name>:

Install the package from the npm registry.

npm install sax

Save Options

Examples

npm install sax
npm install githubname/reponame
npm install @myorg/privatepackage
npm install node-tap --save-dev
npm install dtrace-provider --save-optional
npm install readable-stream --save-exact
npm install ansi-regex --save-bundle

Configuration