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.
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:
A package can be one of the following:
<name>@<version> that is published on the registry<name>@<tag> that points to a specific version<name> with a "latest" tagnpm 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-linksnpm 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
-P, --save-prod: Save to dependencies (default).-D, --save-dev: Save to devDependencies.-O, --save-optional: Save to optionalDependencies.--no-save: Prevent saving to dependencies.npm install saxnpm install githubname/reponamenpm install @myorg/privatepackagenpm install node-tap --save-devnpm install dtrace-provider --save-optionalnpm install readable-stream --save-exactnpm install ansi-regex --save-bundle
save: Save installed packages to a package.json file as dependencies.save-exact: Save dependencies with an exact version.global: Operate in "global" mode, installing packages into the prefix folder.install-strategy: Set the strategy for installing packages in node_modules.legacy-bundling: Install packages in place, without hoisting.global-style: Only install direct dependencies at the top level.omit: Omit specified dependency types from the installation tree on disk.include: Specify which types of dependencies to install.strict-peer-deps: Treat conflicting peerDependencies as an install failure.prefer-dedupe: Prefer to deduplicate packages if possible.package-lock: Ignore package-lock.json files when installing.package-lock-only: Only update the package-lock.json.foreground-scripts: Run all build scripts for installed packages in the foreground process.ignore-scripts: Do not run scripts specified in package.json files.audit: Submit audit reports alongside the current npm command.bin-links: Create symlinks for package executables.fund: Display a funding message at the end of each npm install.dry-run: Report what the install would have done without actually installing anything.cpu: Override CPU architecture of native modules to install.os: Override OS of native modules to install.libc: Override libc of native modules to install.workspace: Enable running a command in the context of the configured workspaces of the current project.workspaces: Run the command in the context of all configured workspaces.include-workspace-root: Include the workspace root when workspaces are enabled for a command.install-links: Pack and install file protocol dependencies as regular dependencies instead of creating a symlink.