1 .\" Generated with Ronnjs 0.3.8
2 .\" http://github.com/kapouer/ronnjs/
4 .TH "NPM" "3" "August 2012" "" ""
7 \fBnpm\fR \-\- node package manager
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)
27 This is the API documentation for npm\.
28 To find documentation of the command line
29 client, see \fBnpm help npm\fR\|\.
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\.
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\.
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\.
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\.
51 To find API documentation for a specific command, run the \fBnpm apihelp\fR
54 .SH "METHODS AND PROPERTIES"
57 \fBnpm\.load(configs, cb)\fR
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\.
68 An object for accessing npm configuration parameters\.
71 \fBnpm\.config\.get(key)\fR
74 \fBnpm\.config\.set(key, val)\fR
77 \fBnpm\.config\.del(key)\fR
83 \fBnpm\.dir\fR or \fBnpm\.root\fR
86 The \fBnode_modules\fR directory where npm will operate\.
92 The prefix where npm is operating\. (Most often the current working
99 The place where npm keeps JSON and tarballs it fetches from the
100 registry (or uploads to the registry)\.
106 npm\'s temporary working directory\.
112 Get the "real" name for a command that has either an alias or
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\.
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\.
128 For example, this would work in a node repl:
133 > npm = require("npm")
134 > npm\.load() // wait a sec\.\.\.
135 > npm\.install("dnode", "express")
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\.
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\.
155 var cmd = npm\.deref("unp") // cmd === "unpublish"