Merge branch 'v0.9.4-release'
[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" "December 2012" "" ""
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.1.70
25 .
26 .SH "DESCRIPTION"
27 This is the API documentation for npm\.
28 To find documentation of the command line
29 client, see \fBnpm help npm\fR\|\.
30 .
31 .P
32 Prior to using npm\'s commands, \fBnpm\.load()\fR must be called with an object hash of
33 top\-level configs\.  In the npm command line client,
34 this set of configs is parsed from the command line options\.  Additional
35 configuration params are loaded from two configuration files\.  See \fBnpm help config\fR for more information\.
36 .
37 .P
38 After that, each of the functions are accessible in the
39 commands object: \fBnpm\.commands\.<cmd>\fR\|\.  See \fBnpm help index\fR for a list of
40 all possible commands\.
41 .
42 .P
43 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
44 commands take other optional arguments\.
45 .
46 .P
47 Configs cannot currently be set on a per function basis, as each call to
48 npm\.config\.set will change the value for \fIall\fR npm commands in that process\.
49 .
50 .P
51 To find API documentation for a specific command, run the \fBnpm apihelp\fR
52 command\.
53 .
54 .SH "METHODS AND PROPERTIES"
55 .
56 .IP "\(bu" 4
57 \fBnpm\.load(configs, cb)\fR
58 .
59 .IP
60 Load the configuration params, and call the \fBcb\fR function once the
61 globalconfig and userconfig files have been loaded as well, or on
62 nextTick if they\'ve already been loaded\.
63 .
64 .IP "\(bu" 4
65 \fBnpm\.config\fR
66 .
67 .IP
68 An object for accessing npm configuration parameters\.
69 .
70 .IP "\(bu" 4
71 \fBnpm\.config\.get(key)\fR
72 .
73 .IP "\(bu" 4
74 \fBnpm\.config\.set(key, val)\fR
75 .
76 .IP "\(bu" 4
77 \fBnpm\.config\.del(key)\fR
78 .
79 .IP "" 0
80
81 .
82 .IP "\(bu" 4
83 \fBnpm\.dir\fR or \fBnpm\.root\fR
84 .
85 .IP
86 The \fBnode_modules\fR directory where npm will operate\.
87 .
88 .IP "\(bu" 4
89 \fBnpm\.prefix\fR
90 .
91 .IP
92 The prefix where npm is operating\.  (Most often the current working
93 directory\.)
94 .
95 .IP "\(bu" 4
96 \fBnpm\.cache\fR
97 .
98 .IP
99 The place where npm keeps JSON and tarballs it fetches from the
100 registry (or uploads to the registry)\.
101 .
102 .IP "\(bu" 4
103 \fBnpm\.tmp\fR
104 .
105 .IP
106 npm\'s temporary working directory\.
107 .
108 .IP "\(bu" 4
109 \fBnpm\.deref\fR
110 .
111 .IP
112 Get the "real" name for a command that has either an alias or
113 abbreviation\.
114 .
115 .IP "" 0
116 .
117 .SH "MAGIC"
118 For each of the methods in the \fBnpm\.commands\fR hash, a method is added to
119 the npm object, which takes a set of positional string arguments rather
120 than an array and a callback\.
121 .
122 .P
123 If the last argument is a callback, then it will use the supplied
124 callback\.  However, if no callback is provided, then it will print out
125 the error or results\.
126 .
127 .P
128 For example, this would work in a node repl:
129 .
130 .IP "" 4
131 .
132 .nf
133 > npm = require("npm")
134 > npm\.load()  // wait a sec\.\.\.
135 > npm\.install("dnode", "express")
136 .
137 .fi
138 .
139 .IP "" 0
140 .
141 .P
142 Note that that \fIwon\'t\fR work in a node program, since the \fBinstall\fR
143 method will get called before the configuration load is completed\.
144 .
145 .SH "ABBREVS"
146 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
147 method names\.  Use the \fBnpm\.deref\fR method to find the real name\.
148 .
149 .P
150 For example:
151 .
152 .IP "" 4
153 .
154 .nf
155 var cmd = npm\.deref("unp") // cmd === "unpublish"
156 .
157 .fi
158 .
159 .IP "" 0
160