deps: upgraded to node-gyp@3.0.3 in npm
[platform/upstream/nodejs.git] / deps / npm / README.md
1 npm(1) -- a JavaScript package manager
2 ==============================
3 [![Build Status](https://img.shields.io/travis/npm/npm/master.svg)](https://travis-ci.org/npm/npm)
4 ## SYNOPSIS
5
6 This is just enough info to get you up and running.
7
8 Much more info available via `npm help` once it's installed.
9
10 ## IMPORTANT
11
12 **You need node v0.8 or higher to run this program.**
13
14 To install an old **and unsupported** version of npm that works on node 0.3
15 and prior, clone the git repo and dig through the old tags and branches.
16
17 ## Super Easy Install
18
19 npm is bundled with [node](http://nodejs.org/download/).
20
21 ### Windows Computers
22
23 [Get the MSI](http://nodejs.org/download/).  npm is in it.
24
25 ### Apple Macintosh Computers
26
27 [Get the pkg](http://nodejs.org/download/).  npm is in it.
28
29 ### Other Sorts of Unices
30
31 Run `make install`.  npm will be installed with node.
32
33 If you want a more fancy pants install (a different version, customized
34 paths, etc.) then read on.
35
36 ## Fancy Install (Unix)
37
38 There's a pretty robust install script at
39 <https://www.npmjs.com/install.sh>.  You can download that and run it.
40
41 Here's an example using curl:
42
43 ```sh
44 curl -L https://www.npmjs.com/install.sh | sh
45 ```
46
47 ### Slightly Fancier
48
49 You can set any npm configuration params with that script:
50
51 ```sh
52 npm_config_prefix=/some/path sh install.sh
53 ```
54
55 Or, you can run it in uber-debuggery mode:
56
57 ```sh
58 npm_debug=1 sh install.sh
59 ```
60
61 ### Even Fancier
62
63 Get the code with git.  Use `make` to build the docs and do other stuff.
64 If you plan on hacking on npm, `make link` is your friend.
65
66 If you've got the npm source code, you can also semi-permanently set
67 arbitrary config keys using the `./configure --key=val ...`, and then
68 run npm commands by doing `node cli.js <cmd> <args>`.  (This is helpful
69 for testing, or running stuff without actually installing npm itself.)
70
71 ## Windows Install or Upgrade
72
73 You can download a zip file from <https://github.com/npm/npm/releases>, and
74 unpack it in the `node_modules\npm\` folder inside node's installation folder.
75
76 To upgrade to npm 2, follow the Windows upgrade instructions in
77 the npm Troubleshooting Guide:
78
79 <https://github.com/npm/npm/wiki/Troubleshooting#upgrading-on-windows>
80
81 If that's not fancy enough for you, then you can fetch the code with
82 git, and mess with it directly.
83
84 ## Installing on Cygwin
85
86 No.
87
88 ## Uninstalling
89
90 So sad to see you go.
91
92 ```sh
93 sudo npm uninstall npm -g
94 ```
95 Or, if that fails,
96
97 ```sh
98 sudo make uninstall
99 ```
100
101 ## More Severe Uninstalling
102
103 Usually, the above instructions are sufficient.  That will remove
104 npm, but leave behind anything you've installed.
105
106 If you would like to remove all the packages that you have installed,
107 then you can use the `npm ls` command to find them, and then `npm rm` to
108 remove them.
109
110 To remove cruft left behind by npm 0.x, you can use the included
111 `clean-old.sh` script file.  You can run it conveniently like this:
112
113 ```sh
114 npm explore npm -g -- sh scripts/clean-old.sh
115 ```
116
117 npm uses two configuration files, one for per-user configs, and another
118 for global (every-user) configs.  You can view them by doing:
119
120 ```sh
121 npm config get userconfig   # defaults to ~/.npmrc
122 npm config get globalconfig # defaults to /usr/local/etc/npmrc
123 ```
124
125 Uninstalling npm does not remove configuration files by default.  You
126 must remove them yourself manually if you want them gone.  Note that
127 this means that future npm installs will not remember the settings that
128 you have chosen.
129
130 ## Using npm Programmatically
131
132 Although npm can be used programmatically, its API is meant for use by the CLI
133 *only*, and no guarantees are made regarding its fitness for any other purpose.
134 If you want to use npm to reliably perform some task, the safest thing to do is
135 to invoke the desired `npm` command with appropriate arguments.
136
137 The semantic version of npm refers to the CLI itself, rather than the
138 underlying API. _The internal API is not guaranteed to remain stable even when
139 npm's version indicates no breaking changes have been made according to
140 semver._
141
142 If you _still_ would like to use npm programmatically, it's _possible_. The API
143 isn't very well documented, but it _is_ rather simple.
144
145 Eventually, npm will be just a thin CLI wrapper around the modules that it
146 depends on, but for now, there are some things that only the CLI can do. You
147 should try using one of npm's dependencies first, and only use the API if what
148 you're trying to do is only supported by npm itself.
149
150 ```javascript
151 var npm = require("npm")
152 npm.load(myConfigObject, function (er) {
153   if (er) return handlError(er)
154   npm.commands.install(["some", "args"], function (er, data) {
155     if (er) return commandFailed(er)
156     // command succeeded, and data might have some info
157   })
158   npm.registry.log.on("log", function (message) { .... })
159 })
160 ```
161
162 The `load` function takes an object hash of the command-line configs.
163 The various `npm.commands.<cmd>` functions take an **array** of
164 positional argument **strings**.  The last argument to any
165 `npm.commands.<cmd>` function is a callback.  Some commands take other
166 optional arguments.  Read the source.
167
168 You cannot set configs individually for any single npm function at this
169 time.  Since `npm` is a singleton, any call to `npm.config.set` will
170 change the value for *all* npm commands in that process.
171
172 See `./bin/npm-cli.js` for an example of pulling config values off of the
173 command line arguments using nopt.  You may also want to check out `npm
174 help config` to learn about all the options you can set there.
175
176 ## More Docs
177
178 Check out the [docs](https://docs.npmjs.com/),
179 especially the [faq](https://docs.npmjs.com/misc/faq).
180
181 You can use the `npm help` command to read any of them.
182
183 If you're a developer, and you want to use npm to publish your program,
184 you should [read this](https://docs.npmjs.com/misc/developers)
185
186 ## Legal Stuff
187
188 "npm" and "The npm Registry" are owned by npm, Inc.
189 All rights reserved.  See the included LICENSE file for more details.
190
191 "Node.js" and "node" are trademarks owned by Joyent, Inc.
192
193 Modules published on the npm registry are not officially endorsed by
194 npm, Inc. or the Node.js project.
195
196 Data published to the npm registry is not part of npm itself, and is
197 the sole property of the publisher.  While every effort is made to
198 ensure accountability, there is absolutely no guarantee, warranty, or
199 assertion expressed or implied as to the quality, fitness for a
200 specific purpose, or lack of malice in any given npm package.
201
202 If you have a complaint about a package in the public npm registry,
203 and cannot [resolve it with the package
204 owner](https://docs.npmjs.com/misc/disputes), please email
205 <support@npmjs.com> and explain the situation.
206
207 Any data published to The npm Registry (including user account
208 information) may be removed or modified at the sole discretion of the
209 npm server administrators.
210
211 ### In plainer english
212
213 npm is the property of npm, Inc.
214
215 If you publish something, it's yours, and you are solely accountable
216 for it.
217
218 If other people publish something, it's theirs.
219
220 Users can publish Bad Stuff.  It will be removed promptly if reported.
221 But there is no vetting process for published modules, and you use
222 them at your own risk.  Please inspect the source.
223
224 If you publish Bad Stuff, we may delete it from the registry, or even
225 ban your account in extreme cases.  So don't do that.
226
227 ## BUGS
228
229 When you find issues, please report them:
230
231 * web:
232   <https://github.com/npm/npm/issues>
233
234 Be sure to include *all* of the output from the npm command that didn't work
235 as expected.  The `npm-debug.log` file is also helpful to provide.
236
237 You can also look for isaacs in #node.js on irc://irc.freenode.net.  He
238 will no doubt tell you to put the output in a gist or email.
239
240 ## SEE ALSO
241
242 * npm(1)
243 * npm-faq(7)
244 * npm-help(1)
245 * npm-index(7)