11cb0ef41Sopenharmony_ci--- 21cb0ef41Sopenharmony_cititle: npm 31cb0ef41Sopenharmony_cisection: 1 41cb0ef41Sopenharmony_cidescription: javascript package manager 51cb0ef41Sopenharmony_ci--- 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ci### Synopsis 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_ci```bash 101cb0ef41Sopenharmony_cinpm 111cb0ef41Sopenharmony_ci``` 121cb0ef41Sopenharmony_ci 131cb0ef41Sopenharmony_ciNote: This command is unaware of workspaces. 141cb0ef41Sopenharmony_ci 151cb0ef41Sopenharmony_ci### Version 161cb0ef41Sopenharmony_ci 171cb0ef41Sopenharmony_ci10.5.0 181cb0ef41Sopenharmony_ci 191cb0ef41Sopenharmony_ci### Description 201cb0ef41Sopenharmony_ci 211cb0ef41Sopenharmony_cinpm is the package manager for the Node JavaScript platform. It puts 221cb0ef41Sopenharmony_cimodules in place so that node can find them, and manages dependency 231cb0ef41Sopenharmony_ciconflicts intelligently. 241cb0ef41Sopenharmony_ci 251cb0ef41Sopenharmony_ciIt is extremely configurable to support a variety of use cases. Most 261cb0ef41Sopenharmony_cicommonly, you use it to publish, discover, install, and develop node 271cb0ef41Sopenharmony_ciprograms. 281cb0ef41Sopenharmony_ci 291cb0ef41Sopenharmony_ciRun `npm help` to get a list of available commands. 301cb0ef41Sopenharmony_ci 311cb0ef41Sopenharmony_ci### Important 321cb0ef41Sopenharmony_ci 331cb0ef41Sopenharmony_cinpm comes preconfigured to use npm's public registry at 341cb0ef41Sopenharmony_cihttps://registry.npmjs.org by default. Use of the npm public registry is 351cb0ef41Sopenharmony_cisubject to terms of use available at 361cb0ef41Sopenharmony_cihttps://docs.npmjs.com/policies/terms. 371cb0ef41Sopenharmony_ci 381cb0ef41Sopenharmony_ciYou can configure npm to use any compatible registry you like, and even 391cb0ef41Sopenharmony_cirun your own registry. Use of someone else's registry is governed by 401cb0ef41Sopenharmony_citheir terms of use. 411cb0ef41Sopenharmony_ci 421cb0ef41Sopenharmony_ci### Introduction 431cb0ef41Sopenharmony_ci 441cb0ef41Sopenharmony_ciYou probably got npm because you want to install stuff. 451cb0ef41Sopenharmony_ci 461cb0ef41Sopenharmony_ciThe very first thing you will most likely want to run in any node 471cb0ef41Sopenharmony_ciprogram is `npm install` to install its dependencies. 481cb0ef41Sopenharmony_ci 491cb0ef41Sopenharmony_ciYou can also run `npm install blerg` to install the latest version of 501cb0ef41Sopenharmony_ci"blerg". Check out [`npm install`](/commands/npm-install) for more 511cb0ef41Sopenharmony_ciinfo. It can do a lot of stuff. 521cb0ef41Sopenharmony_ci 531cb0ef41Sopenharmony_ciUse the `npm search` command to show everything that's available in the 541cb0ef41Sopenharmony_cipublic registry. Use `npm ls` to show everything you've installed. 551cb0ef41Sopenharmony_ci 561cb0ef41Sopenharmony_ci### Dependencies 571cb0ef41Sopenharmony_ci 581cb0ef41Sopenharmony_ciIf a package lists a dependency using a git URL, npm will install that 591cb0ef41Sopenharmony_cidependency using the [`git`](https://github.com/git-guides/install-git) 601cb0ef41Sopenharmony_cicommand and will generate an error if it is not installed. 611cb0ef41Sopenharmony_ci 621cb0ef41Sopenharmony_ciIf one of the packages npm tries to install is a native node module and 631cb0ef41Sopenharmony_cirequires compiling of C++ Code, npm will use 641cb0ef41Sopenharmony_ci[node-gyp](https://github.com/nodejs/node-gyp) for that task. 651cb0ef41Sopenharmony_ciFor a Unix system, [node-gyp](https://github.com/nodejs/node-gyp) 661cb0ef41Sopenharmony_cineeds Python, make and a buildchain like GCC. On Windows, 671cb0ef41Sopenharmony_ciPython and Microsoft Visual Studio C++ are needed. For more information 681cb0ef41Sopenharmony_civisit [the node-gyp repository](https://github.com/nodejs/node-gyp) and 691cb0ef41Sopenharmony_cithe [node-gyp Wiki](https://github.com/nodejs/node-gyp/wiki). 701cb0ef41Sopenharmony_ci 711cb0ef41Sopenharmony_ci### Directories 721cb0ef41Sopenharmony_ci 731cb0ef41Sopenharmony_ciSee [`folders`](/configuring-npm/folders) to learn about where npm puts 741cb0ef41Sopenharmony_cistuff. 751cb0ef41Sopenharmony_ci 761cb0ef41Sopenharmony_ciIn particular, npm has two modes of operation: 771cb0ef41Sopenharmony_ci 781cb0ef41Sopenharmony_ci* local mode: 791cb0ef41Sopenharmony_ci npm installs packages into the current project directory, which 801cb0ef41Sopenharmony_ci defaults to the current working directory. Packages install to 811cb0ef41Sopenharmony_ci `./node_modules`, and bins to `./node_modules/.bin`. 821cb0ef41Sopenharmony_ci* global mode: 831cb0ef41Sopenharmony_ci npm installs packages into the install prefix at 841cb0ef41Sopenharmony_ci `$npm_config_prefix/lib/node_modules` and bins to 851cb0ef41Sopenharmony_ci `$npm_config_prefix/bin`. 861cb0ef41Sopenharmony_ci 871cb0ef41Sopenharmony_ciLocal mode is the default. Use `-g` or `--global` on any command to 881cb0ef41Sopenharmony_cirun in global mode instead. 891cb0ef41Sopenharmony_ci 901cb0ef41Sopenharmony_ci### Developer Usage 911cb0ef41Sopenharmony_ci 921cb0ef41Sopenharmony_ciIf you're using npm to develop and publish your code, check out the 931cb0ef41Sopenharmony_cifollowing help topics: 941cb0ef41Sopenharmony_ci 951cb0ef41Sopenharmony_ci* json: 961cb0ef41Sopenharmony_ci Make a package.json file. See 971cb0ef41Sopenharmony_ci [`package.json`](/configuring-npm/package-json). 981cb0ef41Sopenharmony_ci* link: 991cb0ef41Sopenharmony_ci Links your current working code into Node's path, so that you don't 1001cb0ef41Sopenharmony_ci have to reinstall every time you make a change. Use [`npm 1011cb0ef41Sopenharmony_ci link`](/commands/npm-link) to do this. 1021cb0ef41Sopenharmony_ci* install: 1031cb0ef41Sopenharmony_ci It's a good idea to install things if you don't need the symbolic 1041cb0ef41Sopenharmony_ci link. Especially, installing other peoples code from the registry is 1051cb0ef41Sopenharmony_ci done via [`npm install`](/commands/npm-install) 1061cb0ef41Sopenharmony_ci* adduser: 1071cb0ef41Sopenharmony_ci Create an account or log in. When you do this, npm will store 1081cb0ef41Sopenharmony_ci credentials in the user config file. 1091cb0ef41Sopenharmony_ci* publish: 1101cb0ef41Sopenharmony_ci Use the [`npm publish`](/commands/npm-publish) command to upload your 1111cb0ef41Sopenharmony_ci code to the registry. 1121cb0ef41Sopenharmony_ci 1131cb0ef41Sopenharmony_ci#### Configuration 1141cb0ef41Sopenharmony_ci 1151cb0ef41Sopenharmony_cinpm is extremely configurable. It reads its configuration options from 1161cb0ef41Sopenharmony_ci5 places. 1171cb0ef41Sopenharmony_ci 1181cb0ef41Sopenharmony_ci* Command line switches: 1191cb0ef41Sopenharmony_ci Set a config with `--key val`. All keys take a value, even if they 1201cb0ef41Sopenharmony_ci are booleans (the config parser doesn't know what the options are at 1211cb0ef41Sopenharmony_ci the time of parsing). If you do not provide a value (`--key`) then 1221cb0ef41Sopenharmony_ci the option is set to boolean `true`. 1231cb0ef41Sopenharmony_ci* Environment Variables: 1241cb0ef41Sopenharmony_ci Set any config by prefixing the name in an environment variable with 1251cb0ef41Sopenharmony_ci `npm_config_`. For example, `export npm_config_key=val`. 1261cb0ef41Sopenharmony_ci* User Configs: 1271cb0ef41Sopenharmony_ci The file at `$HOME/.npmrc` is an ini-formatted list of configs. If 1281cb0ef41Sopenharmony_ci present, it is parsed. If the `userconfig` option is set in the cli 1291cb0ef41Sopenharmony_ci or env, that file will be used instead. 1301cb0ef41Sopenharmony_ci* Global Configs: 1311cb0ef41Sopenharmony_ci The file found at `./etc/npmrc` (relative to the global prefix will be 1321cb0ef41Sopenharmony_ci parsed if it is found. See [`npm prefix`](/commands/npm-prefix) for 1331cb0ef41Sopenharmony_ci more info on the global prefix. If the `globalconfig` option is set 1341cb0ef41Sopenharmony_ci in the cli, env, or user config, then that file is parsed instead. 1351cb0ef41Sopenharmony_ci* Defaults: 1361cb0ef41Sopenharmony_ci npm's default configuration options are defined in 1371cb0ef41Sopenharmony_ci `lib/utils/config/definitions.js`. These must not be changed. 1381cb0ef41Sopenharmony_ci 1391cb0ef41Sopenharmony_ciSee [`config`](/using-npm/config) for much much more information. 1401cb0ef41Sopenharmony_ci 1411cb0ef41Sopenharmony_ci### Contributions 1421cb0ef41Sopenharmony_ci 1431cb0ef41Sopenharmony_ciPatches welcome! 1441cb0ef41Sopenharmony_ci 1451cb0ef41Sopenharmony_ciIf you would like to help, but don't know what to work on, read the 1461cb0ef41Sopenharmony_ci[contributing 1471cb0ef41Sopenharmony_ciguidelines](https://github.com/npm/cli/blob/latest/CONTRIBUTING.md) and 1481cb0ef41Sopenharmony_cicheck the issues list. 1491cb0ef41Sopenharmony_ci 1501cb0ef41Sopenharmony_ci### Bugs 1511cb0ef41Sopenharmony_ci 1521cb0ef41Sopenharmony_ciWhen you find issues, please report them: 1531cb0ef41Sopenharmony_ci<https://github.com/npm/cli/issues> 1541cb0ef41Sopenharmony_ci 1551cb0ef41Sopenharmony_ciPlease be sure to follow the template and bug reporting guidelines. 1561cb0ef41Sopenharmony_ci 1571cb0ef41Sopenharmony_ci### Feature Requests 1581cb0ef41Sopenharmony_ci 1591cb0ef41Sopenharmony_ciDiscuss new feature ideas on our discussion forum: 1601cb0ef41Sopenharmony_ci 1611cb0ef41Sopenharmony_ci* <https://github.com/npm/feedback> 1621cb0ef41Sopenharmony_ci 1631cb0ef41Sopenharmony_ciOr suggest formal RFC proposals: 1641cb0ef41Sopenharmony_ci 1651cb0ef41Sopenharmony_ci* <https://github.com/npm/rfcs> 1661cb0ef41Sopenharmony_ci 1671cb0ef41Sopenharmony_ci### See Also 1681cb0ef41Sopenharmony_ci 1691cb0ef41Sopenharmony_ci* [npm help](/commands/npm-help) 1701cb0ef41Sopenharmony_ci* [package.json](/configuring-npm/package-json) 1711cb0ef41Sopenharmony_ci* [npmrc](/configuring-npm/npmrc) 1721cb0ef41Sopenharmony_ci* [npm config](/commands/npm-config) 1731cb0ef41Sopenharmony_ci* [npm install](/commands/npm-install) 1741cb0ef41Sopenharmony_ci* [npm prefix](/commands/npm-prefix) 1751cb0ef41Sopenharmony_ci* [npm publish](/commands/npm-publish) 176