1 .\" Generated with Ronnjs 0.3.8
2 .\" http://github.com/kapouer/ronnjs/
4 .TH "NPM" "3" "August 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 npm help client, see \fBnpm\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 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\.
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\.
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\.
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\.
53 To find API documentation for a specific command, run the \fBnpm apihelp\fR
56 .SH "METHODS AND PROPERTIES"
59 \fBnpm\.load(configs, cb)\fR
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\.
70 An object for accessing npm configuration parameters\.
73 \fBnpm\.config\.get(key)\fR
76 \fBnpm\.config\.set(key, val)\fR
79 \fBnpm\.config\.del(key)\fR
85 \fBnpm\.dir\fR or \fBnpm\.root\fR
88 The \fBnode_modules\fR directory where npm will operate\.
94 The prefix where npm is operating\. (Most often the current working
101 The place where npm keeps JSON and tarballs it fetches from the
102 registry (or uploads to the registry)\.
108 npm\'s temporary working directory\.
114 Get the "real" name for a command that has either an alias or
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\.
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\.
130 For example, this would work in a node repl:
135 > npm = require("npm")
136 > npm\.load() // wait a sec\.\.\.
137 > npm\.install("dnode", "express")
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\.
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\.
157 var cmd = npm\.deref("unp") // cmd === "unpublish"