1NPM(1) NPM(1)
2
3
4
6 npm - javascript package manager
7
8 Synopsis
9 Version
10 8.19.2
11
12 Description
13 npm is the package manager for the Node JavaScript platform. It puts
14 modules in place so that node can find them, and manages dependency
15 conflicts intelligently.
16
17 It is extremely configurable to support a variety of use cases. Most
18 commonly, you use it to publish, discover, install, and develop node
19 programs.
20
21 Run npm help to get a list of available commands.
22
23 Important
24 npm comes preconfigured to use npm's public registry at https://reg‐
25 istry.npmjs.org by default. Use of the npm public registry is subject
26 to terms of use available at https://docs.npmjs.com/policies/terms.
27
28 You can configure npm to use any compatible registry you like, and even
29 run your own registry. Use of someone else's registry is governed by
30 their terms of use.
31
32 Introduction
33 You probably got npm because you want to install stuff.
34
35 The very first thing you will most likely want to run in any node pro‐
36 gram is npm install to install its dependencies.
37
38 You can also run npm install blerg to install the latest version of
39 "blerg". Check out npm help install for more info. It can do a lot of
40 stuff.
41
42 Use the npm search command to show everything that's available in the
43 public registry. Use npm ls to show everything you've installed.
44
45 Dependencies
46 If a package lists a dependency using a git URL, npm will install that
47 dependency using the git https://github.com/git-guides/install-git com‐
48 mand and will generate an error if it is not installed.
49
50 If one of the packages npm tries to install is a native node module and
51 requires compiling of C++ Code, npm will use node-gyp
52 https://github.com/nodejs/node-gyp for that task. For a Unix system,
53 node-gyp https://github.com/nodejs/node-gyp needs Python, make and a
54 buildchain like GCC. On Windows, Python and Microsoft Visual Studio C++
55 are needed. For more information visit the node-gyp repository
56 https://github.com/nodejs/node-gyp and the node-gyp Wiki
57 https://github.com/nodejs/node-gyp/wiki.
58
59 Directories
60 See npm help folders to learn about where npm puts stuff.
61
62 In particular, npm has two modes of operation:
63
64 • local mode: npm installs packages into the current project directory,
65 which defaults to the current working directory. Packages install to
66 ./node_modules, and bins to ./node_modules/.bin.
67
68 • global mode: npm installs packages into the install prefix at
69 $npm_config_prefix/lib/node_modules and bins to $npm_config_pre‐
70 fix/bin.
71
72
73 Local mode is the default. Use -g or --global on any command to run in
74 global mode instead.
75
76 Developer Usage
77 If you're using npm to develop and publish your code, check out the
78 following help topics:
79
80 • json: Make a package.json file. See npm help package.json.
81
82 • link: Links your current working code into Node's path, so that you
83 don't have to reinstall every time you make a change. Use npm help
84 npm link to do this.
85
86 • install: It's a good idea to install things if you don't need the
87 symbolic link. Especially, installing other peoples code from the
88 registry is done via npm help install
89
90 • adduser: Create an account or log in. When you do this, npm will
91 store credentials in the user config file.
92
93 • publish: Use the npm help publish command to upload your code to the
94 registry.
95
96
97 Configuration
98 npm is extremely configurable. It reads its configuration options from
99 5 places.
100
101 • Command line switches: Set a config with --key val. All keys take a
102 value, even if they are booleans (the config parser doesn't know what
103 the options are at the time of parsing). If you do not provide a
104 value (--key) then the option is set to boolean true.
105
106 • Environment Variables: Set any config by prefixing the name in an en‐
107 vironment variable with npm_config_. For example, export npm_con‐
108 fig_key=val.
109
110 • User Configs: The file at $HOME/.npmrc is an ini-formatted list of
111 configs. If present, it is parsed. If the userconfig option is set
112 in the cli or env, that file will be used instead.
113
114 • Global Configs: The file found at ./etc/npmrc (relative to the global
115 prefix will be parsed if it is found. See npm help prefix for more
116 info on the global prefix. If the globalconfig option is set in the
117 cli, env, or user config, then that file is parsed instead.
118
119 • Defaults: npm's default configuration options are defined in
120 lib/utils/config-defs.js. These must not be changed.
121
122
123 See npm help config for much much more information.
124
125 Contributions
126 Patches welcome!
127
128 If you would like to help, but don't know what to work on, read the
129 contributing guidelines https://github.com/npm/cli/blob/latest/CON‐
130 TRIBUTING.md and check the issues list.
131
132 Bugs
133 When you find issues, please report them:
134 https://github.com/npm/cli/issues
135
136 Please be sure to follow the template and bug reporting guidelines.
137
138 Feature Requests
139 Discuss new feature ideas on our discussion forum:
140
141 • https://github.com/npm/feedback
142
143
144 Or suggest formal RFC proposals:
145
146 • https://github.com/npm/rfcs
147
148
149 See Also
150 • npm help help
151
152 • npm help package.json
153
154 • npm help npmrc
155
156 • npm help config
157
158 • npm help install
159
160 • npm help prefix
161
162 • npm help publish
163
164
165
166
167 September 2022 NPM(1)