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