npm: upgrade to v1.3.10
[platform/upstream/nodejs.git] / deps / npm / man / man3 / npm.3
1 .\" Generated with Ronnjs 0.3.8
2 .\" http://github.com/kapouer/ronnjs/
3 .
4 .TH "NPM" "3" "September 2013" "" ""
5 .
6 .SH "NAME"
7 \fBnpm\fR \-\- node package manager
8 .
9 .SH "SYNOPSIS"
10 .
11 .nf
12 var npm = require("npm")
13 npm\.load([configObject], function (er, npm) {
14   // use the npm object, now that it\'s loaded\.
15   npm\.config\.set(key, val)
16   val = npm\.config\.get(key)
17   console\.log("prefix = %s", npm\.prefix)
18   npm\.commands\.install(["package"], cb)
19 })
20 .
21 .fi
22 .
23 .SH "VERSION"
24 1.3.10
25 .
26 .SH "DESCRIPTION"
27 This is the API documentation for npm\.
28 To find documentation of the command line
29 npm help client, see \fBnpm\fR\|\.
30 .
31 .P
32 Prior to using npm\'s commands, \fBnpm\.load()\fR must be called\.
33 If you provide \fBconfigObject\fR as an object hash of top\-level
34 configs, they override the values stored in the various config
35 locations\. In the npm command line client, this set of configs
36 is parsed from the command line options\. Additional configuration
37 npm help  npm help params are loaded from two configuration files\. See \fBnpm\-config\fR, \fBnpm\-confignpm help  \fR, and \fBnpmrc\fR for more information\.
38 .
39 .P
40 After that, each of the functions are accessible in the
41 npm help  commands object: \fBnpm\.commands\.<cmd>\fR\|\.  See \fBnpm\-index\fR for a list of
42 all possible commands\.
43 .
44 .P
45 All commands on the command object take an \fBarray\fR of positional argument \fBstrings\fR\|\. The last argument to any function is a callback\. Some
46 commands take other optional arguments\.
47 .
48 .P
49 Configs cannot currently be set on a per function basis, as each call to
50 npm\.config\.set will change the value for \fIall\fR npm commands in that process\.
51 .
52 .P
53 To find API documentation for a specific command, run the \fBnpm apihelp\fR
54 command\.
55 .
56 .SH "METHODS AND PROPERTIES"
57 .
58 .IP "\(bu" 4
59 \fBnpm\.load(configs, cb)\fR
60 .
61 .IP
62 Load the configuration params, and call the \fBcb\fR function once the
63 globalconfig and userconfig files have been loaded as well, or on
64 nextTick if they\'ve already been loaded\.
65 .
66 .IP "\(bu" 4
67 \fBnpm\.config\fR
68 .
69 .IP
70 An object for accessing npm configuration parameters\.
71 .
72 .IP "\(bu" 4
73 \fBnpm\.config\.get(key)\fR
74 .
75 .IP "\(bu" 4
76 \fBnpm\.config\.set(key, val)\fR
77 .
78 .IP "\(bu" 4
79 \fBnpm\.config\.del(key)\fR
80 .
81 .IP "" 0
82
83 .
84 .IP "\(bu" 4
85 \fBnpm\.dir\fR or \fBnpm\.root\fR
86 .
87 .IP
88 The \fBnode_modules\fR directory where npm will operate\.
89 .
90 .IP "\(bu" 4
91 \fBnpm\.prefix\fR
92 .
93 .IP
94 The prefix where npm is operating\.  (Most often the current working
95 directory\.)
96 .
97 .IP "\(bu" 4
98 \fBnpm\.cache\fR
99 .
100 .IP
101 The place where npm keeps JSON and tarballs it fetches from the
102 registry (or uploads to the registry)\.
103 .
104 .IP "\(bu" 4
105 \fBnpm\.tmp\fR
106 .
107 .IP
108 npm\'s temporary working directory\.
109 .
110 .IP "\(bu" 4
111 \fBnpm\.deref\fR
112 .
113 .IP
114 Get the "real" name for a command that has either an alias or
115 abbreviation\.
116 .
117 .IP "" 0
118 .
119 .SH "MAGIC"
120 For each of the methods in the \fBnpm\.commands\fR hash, a method is added to
121 the npm object, which takes a set of positional string arguments rather
122 than an array and a callback\.
123 .
124 .P
125 If the last argument is a callback, then it will use the supplied
126 callback\.  However, if no callback is provided, then it will print out
127 the error or results\.
128 .
129 .P
130 For example, this would work in a node repl:
131 .
132 .IP "" 4
133 .
134 .nf
135 > npm = require("npm")
136 > npm\.load()  // wait a sec\.\.\.
137 > npm\.install("dnode", "express")
138 .
139 .fi
140 .
141 .IP "" 0
142 .
143 .P
144 Note that that \fIwon\'t\fR work in a node program, since the \fBinstall\fR
145 method will get called before the configuration load is completed\.
146 .
147 .SH "ABBREVS"
148 In order to support \fBnpm ins foo\fR instead of \fBnpm install foo\fR, the \fBnpm\.commands\fR object has a set of abbreviations as well as the full
149 method names\.  Use the \fBnpm\.deref\fR method to find the real name\.
150 .
151 .P
152 For example:
153 .
154 .IP "" 4
155 .
156 .nf
157 var cmd = npm\.deref("unp") // cmd === "unpublish"
158 .
159 .fi
160 .
161 .IP "" 0
162