1 .\" Generated with Ronnjs 0.3.8
2 .\" http://github.com/kapouer/ronnjs/
4 .TH "NPM" "3" "March 2013" "" ""
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\.
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\.
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\.
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\.
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\.
54 To find API documentation for a specific command, run the \fBnpm apihelp\fR
57 .SH "METHODS AND PROPERTIES"
60 \fBnpm\.load(configs, cb)\fR
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\.
71 An object for accessing npm configuration parameters\.
74 \fBnpm\.config\.get(key)\fR
77 \fBnpm\.config\.set(key, val)\fR
80 \fBnpm\.config\.del(key)\fR
86 \fBnpm\.dir\fR or \fBnpm\.root\fR
89 The \fBnode_modules\fR directory where npm will operate\.
95 The prefix where npm is operating\. (Most often the current working
102 The place where npm keeps JSON and tarballs it fetches from the
103 registry (or uploads to the registry)\.
109 npm\'s temporary working directory\.
115 Get the "real" name for a command that has either an alias or
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\.
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\.
131 For example, this would work in a node repl:
136 > npm = require("npm")
137 > npm\.load() // wait a sec\.\.\.
138 > npm\.install("dnode", "express")
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\.
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\.
158 var cmd = npm\.deref("unp") // cmd === "unpublish"