9ed084297a515ced9d1516c35b08c9b531106379
[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 comes with [node](http://nodejs.org/download/) now.
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     curl -L https://npmjs.com/install.sh | sh
44
45 ### Slightly Fancier
46
47 You can set any npm configuration params with that script:
48
49     npm_config_prefix=/some/path sh install.sh
50
51 Or, you can run it in uber-debuggery mode:
52
53     npm_debug=1 sh install.sh
54
55 ### Even Fancier
56
57 Get the code with git.  Use `make` to build the docs and do other stuff.
58 If you plan on hacking on npm, `make link` is your friend.
59
60 If you've got the npm source code, you can also semi-permanently set
61 arbitrary config keys using the `./configure --key=val ...`, and then
62 run npm commands by doing `node cli.js <cmd> <args>`.  (This is helpful
63 for testing, or running stuff without actually installing npm itself.)
64
65 ## Windows Install or Upgrade
66
67 You can download a zip file from <https://github.com/npm/npm/releases>, and unpack it
68 in the same folder where node.exe lives.
69
70 The latest version in a zip file is 1.4.12.  To upgrade to npm 2, follow the
71 Windows upgrade instructions in the npm Troubleshooting Guide:
72
73 <https://github.com/npm/npm/wiki/Troubleshooting#upgrading-on-windows>
74
75 If that's not fancy enough for you, then you can fetch the code with
76 git, and mess with it directly.
77
78 ## Installing on Cygwin
79
80 No.
81
82 ## Uninstalling
83
84 So sad to see you go.
85
86     sudo npm uninstall npm -g
87
88 Or, if that fails,
89
90     sudo make uninstall
91
92 ## More Severe Uninstalling
93
94 Usually, the above instructions are sufficient.  That will remove
95 npm, but leave behind anything you've installed.
96
97 If you would like to remove all the packages that you have installed,
98 then you can use the `npm ls` command to find them, and then `npm rm` to
99 remove them.
100
101 To remove cruft left behind by npm 0.x, you can use the included
102 `clean-old.sh` script file.  You can run it conveniently like this:
103
104     npm explore npm -g -- sh scripts/clean-old.sh
105
106 npm uses two configuration files, one for per-user configs, and another
107 for global (every-user) configs.  You can view them by doing:
108
109     npm config get userconfig   # defaults to ~/.npmrc
110     npm config get globalconfig # defaults to /usr/local/etc/npmrc
111
112 Uninstalling npm does not remove configuration files by default.  You
113 must remove them yourself manually if you want them gone.  Note that
114 this means that future npm installs will not remember the settings that
115 you have chosen.
116
117 ## Using npm Programmatically
118
119 If you would like to use npm programmatically, you can do that.
120 It's not very well documented, but it *is* rather simple.
121
122 Most of the time, unless you actually want to do all the things that
123 npm does, you should try using one of npm's dependencies rather than
124 using npm itself, if possible.
125
126 Eventually, npm will be just a thin cli wrapper around the modules
127 that it depends on, but for now, there are some things that you must
128 use npm itself to do.
129
130     var npm = require("npm")
131     npm.load(myConfigObject, function (er) {
132       if (er) return handlError(er)
133       npm.commands.install(["some", "args"], function (er, data) {
134         if (er) return commandFailed(er)
135         // command succeeded, and data might have some info
136       })
137       npm.registry.log.on("log", function (message) { .... })
138     })
139
140 The `load` function takes an object hash of the command-line configs.
141 The various `npm.commands.<cmd>` functions take an **array** of
142 positional argument **strings**.  The last argument to any
143 `npm.commands.<cmd>` function is a callback.  Some commands take other
144 optional arguments.  Read the source.
145
146 You cannot set configs individually for any single npm function at this
147 time.  Since `npm` is a singleton, any call to `npm.config.set` will
148 change the value for *all* npm commands in that process.
149
150 See `./bin/npm-cli.js` for an example of pulling config values off of the
151 command line arguments using nopt.  You may also want to check out `npm
152 help config` to learn about all the options you can set there.
153
154 ## More Docs
155
156 Check out the [docs](https://docs.npmjs.com/),
157 especially the [faq](https://docs.npmjs.com/misc/faq).
158
159 You can use the `npm help` command to read any of them.
160
161 If you're a developer, and you want to use npm to publish your program,
162 you should [read this](https://docs.npmjs.com/misc/developers)
163
164 ## Legal Stuff
165
166 "npm" and "The npm Registry" are owned by npm, Inc.
167 All rights reserved.  See the included LICENSE file for more details.
168
169 "Node.js" and "node" are trademarks owned by Joyent, Inc.
170
171 Modules published on the npm registry are not officially endorsed by
172 npm, Inc. or the Node.js project.
173
174 Data published to the npm registry is not part of npm itself, and is
175 the sole property of the publisher.  While every effort is made to
176 ensure accountability, there is absolutely no guarantee, warranty, or
177 assertion expressed or implied as to the quality, fitness for a
178 specific purpose, or lack of malice in any given npm package.
179
180 If you have a complaint about a package in the public npm registry,
181 and cannot [resolve it with the package
182 owner](https://docs.npmjs.com/misc/disputes), please email
183 <support@npmjs.com> and explain the situation.
184
185 Any data published to The npm Registry (including user account
186 information) may be removed or modified at the sole discretion of the
187 npm server administrators.
188
189 ### In plainer english
190
191 npm is the property of npm, Inc.
192
193 If you publish something, it's yours, and you are solely accountable
194 for it.
195
196 If other people publish something, it's theirs.
197
198 Users can publish Bad Stuff.  It will be removed promptly if reported.
199 But there is no vetting process for published modules, and you use
200 them at your own risk.  Please inspect the source.
201
202 If you publish Bad Stuff, we may delete it from the registry, or even
203 ban your account in extreme cases.  So don't do that.
204
205 ## BUGS
206
207 When you find issues, please report them:
208
209 * web:
210   <https://github.com/npm/npm/issues>
211
212 Be sure to include *all* of the output from the npm command that didn't work
213 as expected.  The `npm-debug.log` file is also helpful to provide.
214
215 You can also look for isaacs in #node.js on irc://irc.freenode.net.  He
216 will no doubt tell you to put the output in a gist or email.
217
218 ## SEE ALSO
219
220 * npm(1)
221 * npm-faq(7)
222 * npm-help(1)
223 * npm-index(7)