9a34b83adb2fff6eaf34a17ddb16890c1a6700f3
[platform/upstream/nodejs.git] / deps / npm / html / doc / README.html
1 <!doctype html>
2 <html>
3   <title>README</title>
4   <meta http-equiv="content-type" value="text/html;utf-8">
5   <link rel="stylesheet" type="text/css" href="../static/style.css">
6
7   <body>
8     <div id="wrapper">
9 <h1><a href="cli/npm.html">npm</a></h1> <p>node package manager</p>
10
11 <h2 id="SYNOPSIS">SYNOPSIS</h2>
12
13 <p>This is just enough info to get you up and running.</p>
14
15 <p>Much more info available via <code>npm help</code> once it&#39;s installed.</p>
16
17 <h2 id="IMPORTANT">IMPORTANT</h2>
18
19 <p><strong>You need node v0.8 or higher to run this program.</strong></p>
20
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>
23
24 <h2 id="Super-Easy-Install">Super Easy Install</h2>
25
26 <p>npm comes with node now.</p>
27
28 <h3 id="Windows-Computers">Windows Computers</h3>
29
30 <p>Get the MSI.  npm is in it.</p>
31
32 <h3 id="Apple-Macintosh-Computers">Apple Macintosh Computers</h3>
33
34 <p>Get the pkg.  npm is in it.</p>
35
36 <h3 id="Other-Sorts-of-Unices">Other Sorts of Unices</h3>
37
38 <p>Run <code>make install</code>.  npm will be installed with node.</p>
39
40 <p>If you want a more fancy pants install (a different version, customized
41 paths, etc.) then read on.</p>
42
43 <h2 id="Fancy-Install-Unix">Fancy Install (Unix)</h2>
44
45 <p>There&#39;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>
47
48 <h3 id="Slightly-Fancier">Slightly Fancier</h3>
49
50 <p>You can set any npm configuration params with that script:</p>
51
52 <pre><code>npm_config_prefix=/some/path sh install.sh</code></pre>
53
54 <p>Or, you can run it in uber-debuggery mode:</p>
55
56 <pre><code>npm_debug=1 sh install.sh</code></pre>
57
58 <h3 id="Even-Fancier">Even Fancier</h3>
59
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>
62
63 <p>If you&#39;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 &lt;cmd&gt; &lt;args&gt;</code>.  (This is helpful
66 for testing, or running stuff without actually installing npm itself.)</p>
67
68 <h2 id="Fancy-Windows-Install">Fancy Windows Install</h2>
69
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>
72
73 <p>If that&#39;s not fancy enough for you, then you can fetch the code with
74 git, and mess with it directly.</p>
75
76 <h2 id="Installing-on-Cygwin">Installing on Cygwin</h2>
77
78 <p>No.</p>
79
80 <h2 id="Permissions-when-Using-npm-to-Install-Other-Stuff">Permissions when Using npm to Install Other Stuff</h2>
81
82 <p><strong>tl;dr</strong></p>
83
84 <ul><li>Use <code>sudo</code> for greater safety.  Or don&#39;t, if you prefer not to.</li><li>npm will downgrade permissions if it&#39;s root before running any build
85 scripts that package authors specified.</li></ul>
86
87 <h3 id="More-details">More details...</h3>
88
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>
92
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>
95
96 <p>If you would like to ensure that npm <strong>always</strong> runs scripts as the
97 &quot;nobody&quot; user, and have it fail if it cannot downgrade permissions, then
98 set the following configuration param:</p>
99
100 <pre><code>npm config set unsafe-perm false</code></pre>
101
102 <p>This will prevent running in unsafe mode, even as non-root users.</p>
103
104 <h2 id="Uninstalling">Uninstalling</h2>
105
106 <p>So sad to see you go.</p>
107
108 <pre><code>sudo npm uninstall npm -g</code></pre>
109
110 <p>Or, if that fails,</p>
111
112 <pre><code>sudo make uninstall</code></pre>
113
114 <h2 id="More-Severe-Uninstalling">More Severe Uninstalling</h2>
115
116 <p>Usually, the above instructions are sufficient.  That will remove
117 npm, but leave behind anything you&#39;ve installed.</p>
118
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
121 remove them.</p>
122
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>
125
126 <pre><code>npm explore npm -g -- sh scripts/clean-old.sh</code></pre>
127
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>
130
131 <pre><code>npm config get userconfig   # defaults to ~/.npmrc
132 npm config get globalconfig # defaults to /usr/local/etc/npmrc</code></pre>
133
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
137 you have chosen.</p>
138
139 <h2 id="Using-npm-Programmatically">Using npm Programmatically</h2>
140
141 <p>If you would like to use npm programmatically, you can do that.
142 It&#39;s not very well documented, but it <em>is</em> rather simple.</p>
143
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&#39;s dependencies rather than
146 using npm itself, if possible.</p>
147
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>
151
152 <pre><code>var npm = require(&quot;npm&quot;)
153 npm.load(myConfigObject, function (er) {
154   if (er) return handlError(er)
155   npm.commands.install([&quot;some&quot;, &quot;args&quot;], function (er, data) {
156     if (er) return commandFailed(er)
157     // command succeeded, and data might have some info
158   })
159   npm.on(&quot;log&quot;, function (message) { .... })
160 })</code></pre>
161
162 <p>The <code>load</code> function takes an object hash of the command-line configs.
163 The various <code>npm.commands.&lt;cmd&gt;</code> functions take an <strong>array</strong> of
164 positional argument <strong>strings</strong>.  The last argument to any
165 <code>npm.commands.&lt;cmd&gt;</code> function is a callback.  Some commands take other
166 optional arguments.  Read the source.</p>
167
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>
171
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>
175
176 <h2 id="More-Docs">More Docs</h2>
177
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>
180
181 <p>You can use the <code>npm help</code> command to read any of them.</p>
182
183 <p>If you&#39;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>
185
186 <h2 id="Legal-Stuff">Legal Stuff</h2>
187
188 <p>&quot;npm&quot; and &quot;the npm registry&quot; are owned by Isaac Z. Schlueter.
189 All rights reserved.  See the included LICENSE file for more details.</p>
190
191 <p>&quot;Node.js&quot; and &quot;node&quot; 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>
194
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>
202
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>
206
207 <h3 id="In-plain-english">In plain english</h3>
208
209 <p>This is mine; not my employer&#39;s, not Node&#39;s, not Joyent&#39;s, not Ryan
210 Dahl&#39;s.</p>
211
212 <p>If you publish something, it&#39;s yours, and you are solely accountable
213 for it.  Not me, not Node, not Joyent, not Ryan Dahl.</p>
214
215 <p>If other people publish something, it&#39;s theirs.  Not mine, not Node&#39;s,
216 not Joyent&#39;s, not Ryan Dahl&#39;s.</p>
217
218 <p>Yes, you can publish something evil.  It will be removed promptly if
219 reported, and we&#39;ll lose respect for you.  But there is no vetting
220 process for published modules.</p>
221
222 <p>If this concerns you, inspect the source before using packages.</p>
223
224 <h2 id="BUGS">BUGS</h2>
225
226 <p>When you find issues, please report them:</p>
227
228 <ul><li>web:
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>
231
232 <p>Be sure to include <em>all</em> of the output from the npm command that didn&#39;t work
233 as expected.  The <code>npm-debug.log</code> file is also helpful to provide.</p>
234
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>
237
238 <h2 id="SEE-ALSO">SEE ALSO</h2>
239
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>
241 </div>
242 <p id="footer"><a href="../doc/README.html">README</a> &mdash; npm@1.3.15</p>
243 <script>
244 ;(function () {
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]/)
250         && el.id
251   })
252 var l = 2
253   , toc = document.createElement("ul")
254 toc.innerHTML = els.map(function (el) {
255   var i = el.tagName.charAt(1)
256     , out = ""
257   while (i > l) {
258     out += "<ul>"
259     l ++
260   }
261   while (i < l) {
262     out += "</ul>"
263     l --
264   }
265   out += "<li><a href='#" + el.id + "'>" +
266     ( el.innerText || el.text || el.innerHTML)
267     + "</a>"
268   return out
269 }).join("\n")
270 toc.id = "toc"
271 document.body.appendChild(toc)
272 })()
273 </script>