4 <meta http-equiv="content-type" value="text/html;utf-8">
5 <link rel="stylesheet" type="text/css" href="../static/style.css">
9 <h1><a href="cli/npm.html">npm</a></h1> <p>node package manager</p>
11 <h2 id="SYNOPSIS">SYNOPSIS</h2>
13 <p>This is just enough info to get you up and running.</p>
15 <p>Much more info available via <code>npm help</code> once it's installed.</p>
17 <h2 id="IMPORTANT">IMPORTANT</h2>
19 <p><strong>You need node v0.8 or higher to run this program.</strong></p>
21 <p>To install an old <strong>and unsupported</strong> version of npm that works on node 0.3
22 and prior, clone the git repo and dig through the old tags and branches.</p>
24 <h2 id="Super-Easy-Install">Super Easy Install</h2>
26 <p>npm comes with node now.</p>
28 <h3 id="Windows-Computers">Windows Computers</h3>
30 <p>Get the MSI. npm is in it.</p>
32 <h3 id="Apple-Macintosh-Computers">Apple Macintosh Computers</h3>
34 <p>Get the pkg. npm is in it.</p>
36 <h3 id="Other-Sorts-of-Unices">Other Sorts of Unices</h3>
38 <p>Run <code>make install</code>. npm will be installed with node.</p>
40 <p>If you want a more fancy pants install (a different version, customized
41 paths, etc.) then read on.</p>
43 <h2 id="Fancy-Install-Unix">Fancy Install (Unix)</h2>
45 <p>There's a pretty robust install script at
46 <a href="https://npmjs.org/install.sh">https://npmjs.org/install.sh</a>. You can download that and run it.</p>
48 <h3 id="Slightly-Fancier">Slightly Fancier</h3>
50 <p>You can set any npm configuration params with that script:</p>
52 <pre><code>npm_config_prefix=/some/path sh install.sh</code></pre>
54 <p>Or, you can run it in uber-debuggery mode:</p>
56 <pre><code>npm_debug=1 sh install.sh</code></pre>
58 <h3 id="Even-Fancier">Even Fancier</h3>
60 <p>Get the code with git. Use <code>make</code> to build the docs and do other stuff.
61 If you plan on hacking on npm, <code>make link</code> is your friend.</p>
63 <p>If you've got the npm source code, you can also semi-permanently set
64 arbitrary config keys using the <code>./configure --key=val ...</code>, and then
65 run npm commands by doing <code>node cli.js <cmd> <args></code>. (This is helpful
66 for testing, or running stuff without actually installing npm itself.)</p>
68 <h2 id="Fancy-Windows-Install">Fancy Windows Install</h2>
70 <p>You can download a zip file from <a href="https://npmjs.org/dist/">https://npmjs.org/dist/</a>, and unpack it
71 in the same folder where node.exe lives.</p>
73 <p>If that's not fancy enough for you, then you can fetch the code with
74 git, and mess with it directly.</p>
76 <h2 id="Installing-on-Cygwin">Installing on Cygwin</h2>
80 <h2 id="Permissions-when-Using-npm-to-Install-Other-Stuff">Permissions when Using npm to Install Other Stuff</h2>
82 <p><strong>tl;dr</strong></p>
84 <ul><li>Use <code>sudo</code> for greater safety. Or don't, if you prefer not to.</li><li>npm will downgrade permissions if it's root before running any build
85 scripts that package authors specified.</li></ul>
87 <h3 id="More-details">More details...</h3>
89 <p>As of version 0.3, it is recommended to run npm as root.
90 This allows npm to change the user identifier to the <code>nobody</code> user prior
91 to running any package build or test commands.</p>
93 <p>If you are not the root user, or if you are on a platform that does not
94 support uid switching, then npm will not attempt to change the userid.</p>
96 <p>If you would like to ensure that npm <strong>always</strong> runs scripts as the
97 "nobody" user, and have it fail if it cannot downgrade permissions, then
98 set the following configuration param:</p>
100 <pre><code>npm config set unsafe-perm false</code></pre>
102 <p>This will prevent running in unsafe mode, even as non-root users.</p>
104 <h2 id="Uninstalling">Uninstalling</h2>
106 <p>So sad to see you go.</p>
108 <pre><code>sudo npm uninstall npm -g</code></pre>
110 <p>Or, if that fails,</p>
112 <pre><code>sudo make uninstall</code></pre>
114 <h2 id="More-Severe-Uninstalling">More Severe Uninstalling</h2>
116 <p>Usually, the above instructions are sufficient. That will remove
117 npm, but leave behind anything you've installed.</p>
119 <p>If you would like to remove all the packages that you have installed,
120 then you can use the <code>npm ls</code> command to find them, and then <code>npm rm</code> to
123 <p>To remove cruft left behind by npm 0.x, you can use the included
124 <code>clean-old.sh</code> script file. You can run it conveniently like this:</p>
126 <pre><code>npm explore npm -g -- sh scripts/clean-old.sh</code></pre>
128 <p>npm uses two configuration files, one for per-user configs, and another
129 for global (every-user) configs. You can view them by doing:</p>
131 <pre><code>npm config get userconfig # defaults to ~/.npmrc
132 npm config get globalconfig # defaults to /usr/local/etc/npmrc</code></pre>
134 <p>Uninstalling npm does not remove configuration files by default. You
135 must remove them yourself manually if you want them gone. Note that
136 this means that future npm installs will not remember the settings that
139 <h2 id="Using-npm-Programmatically">Using npm Programmatically</h2>
141 <p>If you would like to use npm programmatically, you can do that.
142 It's not very well documented, but it <em>is</em> rather simple.</p>
144 <p>Most of the time, unless you actually want to do all the things that
145 npm does, you should try using one of npm's dependencies rather than
146 using npm itself, if possible.</p>
148 <p>Eventually, npm will be just a thin cli wrapper around the modules
149 that it depends on, but for now, there are some things that you must
150 use npm itself to do.</p>
152 <pre><code>var npm = require("npm")
153 npm.load(myConfigObject, function (er) {
154 if (er) return handlError(er)
155 npm.commands.install(["some", "args"], function (er, data) {
156 if (er) return commandFailed(er)
157 // command succeeded, and data might have some info
159 npm.on("log", function (message) { .... })
162 <p>The <code>load</code> function takes an object hash of the command-line configs.
163 The various <code>npm.commands.<cmd></code> functions take an <strong>array</strong> of
164 positional argument <strong>strings</strong>. The last argument to any
165 <code>npm.commands.<cmd></code> function is a callback. Some commands take other
166 optional arguments. Read the source.</p>
168 <p>You cannot set configs individually for any single npm function at this
169 time. Since <code>npm</code> is a singleton, any call to <code>npm.config.set</code> will
170 change the value for <em>all</em> npm commands in that process.</p>
172 <p>See <code>./bin/npm-cli.js</code> for an example of pulling config values off of the
173 command line arguments using nopt. You may also want to check out <code>npm
174 help config</code> to learn about all the options you can set there.</p>
176 <h2 id="More-Docs">More Docs</h2>
178 <p>Check out the <a href="https://npmjs.org/doc/">docs</a>,
179 especially the <a href="https://npmjs.org/doc/faq.html">faq</a>.</p>
181 <p>You can use the <code>npm help</code> command to read any of them.</p>
183 <p>If you're a developer, and you want to use npm to publish your program,
184 you should <a href="https://npmjs.org/doc/developers.html">read this</a></p>
186 <h2 id="Legal-Stuff">Legal Stuff</h2>
188 <p>"npm" and "the npm registry" are owned by Isaac Z. Schlueter.
189 All rights reserved. See the included LICENSE file for more details.</p>
191 <p>"Node.js" and "node" are trademarks owned by Joyent, Inc. npm is not
192 officially part of the Node.js project, and is neither owned by nor
193 officially affiliated with Joyent, Inc.</p>
195 <p>The packages in the npm registry are not part of npm itself, and are the
196 sole property of their respective maintainers. While every effort is
197 made to ensure accountability, there is absolutely no guarantee,
198 warrantee, or assertion made as to the quality, fitness for a specific
199 purpose, or lack of malice in any given npm package. Modules
200 published on the npm registry are not affiliated with or endorsed by
201 Joyent, Inc., Isaac Z. Schlueter, Ryan Dahl, or the Node.js project.</p>
203 <p>If you have a complaint about a package in the npm registry, and cannot
204 resolve it with the package owner, please express your concerns to
205 Isaac Z. Schlueter at <a href="mailto:i@izs.me">i@izs.me</a>.</p>
207 <h3 id="In-plain-english">In plain english</h3>
209 <p>This is mine; not my employer's, not Node's, not Joyent's, not Ryan
212 <p>If you publish something, it's yours, and you are solely accountable
213 for it. Not me, not Node, not Joyent, not Ryan Dahl.</p>
215 <p>If other people publish something, it's theirs. Not mine, not Node's,
216 not Joyent's, not Ryan Dahl's.</p>
218 <p>Yes, you can publish something evil. It will be removed promptly if
219 reported, and we'll lose respect for you. But there is no vetting
220 process for published modules.</p>
222 <p>If this concerns you, inspect the source before using packages.</p>
224 <h2 id="BUGS">BUGS</h2>
226 <p>When you find issues, please report them:</p>
229 <a href="https://github.com/isaacs/npm/issues">https://github.com/isaacs/npm/issues</a></li><li>email:
230 <a href="mailto:npm-@googlegroups.com">npm-@googlegroups.com</a></li></ul>
232 <p>Be sure to include <em>all</em> of the output from the npm command that didn't work
233 as expected. The <code>npm-debug.log</code> file is also helpful to provide.</p>
235 <p>You can also look for isaacs in #node.js on irc://irc.freenode.net. He
236 will no doubt tell you to put the output in a gist or email.</p>
238 <h2 id="SEE-ALSO">SEE ALSO</h2>
240 <ul><li><a href="cli/npm.html">npm(1)</a></li><li><a href="misc/npm-faq.html">npm-faq(7)</a></li><li><a href="cli/npm-help.html">npm-help(1)</a></li><li><a href="misc/npm-index.html">npm-index(7)</a></li></ul>
242 <p id="footer"><a href="../doc/README.html">README</a> — npm@1.3.19</p>
245 var wrapper = document.getElementById("wrapper")
246 var els = Array.prototype.slice.call(wrapper.getElementsByTagName("*"), 0)
247 .filter(function (el) {
248 return el.parentNode === wrapper
249 && el.tagName.match(/H[1-6]/)
253 , toc = document.createElement("ul")
254 toc.innerHTML = els.map(function (el) {
255 var i = el.tagName.charAt(1)
265 out += "<li><a href='#" + el.id + "'>" +
266 ( el.innerText || el.text || el.innerHTML)
271 document.body.appendChild(toc)