The data contained in this repository can be downloaded to your computer using one of several clients.
Please see the documentation of your version control software client for more information.

Please select the desired protocol below to get the URL.

This URL has Read-Only access.

Statistics
| Branch: | Revision:

main_repo / deps / npm / man / man3 / npm.3 @ 5aef65a9

History | View | Annotate | Download (3.68 KB)

1
.\" Generated with Ronnjs 0.3.8
2
.\" http://github.com/kapouer/ronnjs/
3
.
4
.TH "NPM" "3" "February 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.2.10
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\.
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
params are loaded from two configuration files\. See \fBnpm help config\fR
38
for more information\.
39
.
40
.P
41
After that, each of the functions are accessible in the
42
commands object: \fBnpm\.commands\.<cmd>\fR\|\.  See \fBnpm help index\fR for a list of
43
all possible commands\.
44
.
45
.P
46
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
47
commands take other optional arguments\.
48
.
49
.P
50
Configs cannot currently be set on a per function basis, as each call to
51
npm\.config\.set will change the value for \fIall\fR npm commands in that process\.
52
.
53
.P
54
To find API documentation for a specific command, run the \fBnpm apihelp\fR
55
command\.
56
.
57
.SH "METHODS AND PROPERTIES"
58
.
59
.IP "\(bu" 4
60
\fBnpm\.load(configs, cb)\fR
61
.
62
.IP
63
Load the configuration params, and call the \fBcb\fR function once the
64
globalconfig and userconfig files have been loaded as well, or on
65
nextTick if they\'ve already been loaded\.
66
.
67
.IP "\(bu" 4
68
\fBnpm\.config\fR
69
.
70
.IP
71
An object for accessing npm configuration parameters\.
72
.
73
.IP "\(bu" 4
74
\fBnpm\.config\.get(key)\fR
75
.
76
.IP "\(bu" 4
77
\fBnpm\.config\.set(key, val)\fR
78
.
79
.IP "\(bu" 4
80
\fBnpm\.config\.del(key)\fR
81
.
82
.IP "" 0
83

    
84
.
85
.IP "\(bu" 4
86
\fBnpm\.dir\fR or \fBnpm\.root\fR
87
.
88
.IP
89
The \fBnode_modules\fR directory where npm will operate\.
90
.
91
.IP "\(bu" 4
92
\fBnpm\.prefix\fR
93
.
94
.IP
95
The prefix where npm is operating\.  (Most often the current working
96
directory\.)
97
.
98
.IP "\(bu" 4
99
\fBnpm\.cache\fR
100
.
101
.IP
102
The place where npm keeps JSON and tarballs it fetches from the
103
registry (or uploads to the registry)\.
104
.
105
.IP "\(bu" 4
106
\fBnpm\.tmp\fR
107
.
108
.IP
109
npm\'s temporary working directory\.
110
.
111
.IP "\(bu" 4
112
\fBnpm\.deref\fR
113
.
114
.IP
115
Get the "real" name for a command that has either an alias or
116
abbreviation\.
117
.
118
.IP "" 0
119
.
120
.SH "MAGIC"
121
For each of the methods in the \fBnpm\.commands\fR hash, a method is added to
122
the npm object, which takes a set of positional string arguments rather
123
than an array and a callback\.
124
.
125
.P
126
If the last argument is a callback, then it will use the supplied
127
callback\.  However, if no callback is provided, then it will print out
128
the error or results\.
129
.
130
.P
131
For example, this would work in a node repl:
132
.
133
.IP "" 4
134
.
135
.nf
136
> npm = require("npm")
137
> npm\.load()  // wait a sec\.\.\.
138
> npm\.install("dnode", "express")
139
.
140
.fi
141
.
142
.IP "" 0
143
.
144
.P
145
Note that that \fIwon\'t\fR work in a node program, since the \fBinstall\fR
146
method will get called before the configuration load is completed\.
147
.
148
.SH "ABBREVS"
149
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
150
method names\.  Use the \fBnpm\.deref\fR method to find the real name\.
151
.
152
.P
153
For example:
154
.
155
.IP "" 4
156
.
157
.nf
158
var cmd = npm\.deref("unp") // cmd === "unpublish"
159
.
160
.fi
161
.
162
.IP "" 0
163