]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/doc/api/npm.md
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / doc / api / npm.md
1 npm(3) -- javascript package manager
2 ====================================
3
4 ## SYNOPSIS
5
6     var npm = require("npm")
7     npm.load([configObject, ]function (er, npm) {
8       // use the npm object, now that it's loaded.
9
10       npm.config.set(key, val)
11       val = npm.config.get(key)
12
13       console.log("prefix = %s", npm.prefix)
14
15       npm.commands.install(["package"], cb)
16     })
17
18 ## VERSION
19
20 @VERSION@
21
22 ## DESCRIPTION
23
24 This is the API documentation for npm.
25 To find documentation of the command line
26 client, see `npm(1)`.
27
28 Prior to using npm's commands, `npm.load()` must be called.  If you provide
29 `configObject` as an object map of top-level configs, they override the values
30 stored in the various config locations. In the npm command line client, this
31 set of configs is parsed from the command line options. Additional
32 configuration params are loaded from two configuration files. See
33 `npm-config(1)`, `npm-config(7)`, and `npmrc(5)` for more information.
34
35 After that, each of the functions are accessible in the
36 commands object: `npm.commands.<cmd>`.  See `npm-index(7)` for a list of
37 all possible commands.
38
39 All commands on the command object take an **array** of positional argument
40 **strings**. The last argument to any function is a callback. Some
41 commands take other optional arguments.
42
43 Configs cannot currently be set on a per function basis, as each call to
44 npm.config.set will change the value for *all* npm commands in that process.
45
46 To find API documentation for a specific command, run the `npm apihelp`
47 command.
48
49 ## METHODS AND PROPERTIES
50
51 * `npm.load(configs, cb)`
52
53     Load the configuration params, and call the `cb` function once the
54     globalconfig and userconfig files have been loaded as well, or on
55     nextTick if they've already been loaded.
56
57 * `npm.config`
58
59     An object for accessing npm configuration parameters.
60
61     * `npm.config.get(key)`
62     * `npm.config.set(key, val)`
63     * `npm.config.del(key)`
64
65 * `npm.dir` or `npm.root`
66
67     The `node_modules` directory where npm will operate.
68
69 * `npm.prefix`
70
71     The prefix where npm is operating.  (Most often the current working
72     directory.)
73
74 * `npm.cache`
75
76     The place where npm keeps JSON and tarballs it fetches from the
77     registry (or uploads to the registry).
78
79 * `npm.tmp`
80
81     npm's temporary working directory.
82
83 * `npm.deref`
84
85     Get the "real" name for a command that has either an alias or
86     abbreviation.
87
88 ## MAGIC
89
90 For each of the methods in the `npm.commands` object, a method is added to the
91 npm object, which takes a set of positional string arguments rather than an
92 array and a callback.
93
94 If the last argument is a callback, then it will use the supplied
95 callback.  However, if no callback is provided, then it will print out
96 the error or results.
97
98 For example, this would work in a node repl:
99
100     > npm = require("npm")
101     > npm.load()  // wait a sec...
102     > npm.install("dnode", "express")
103
104 Note that that *won't* work in a node program, since the `install`
105 method will get called before the configuration load is completed.
106
107 ## ABBREVS
108
109 In order to support `npm ins foo` instead of `npm install foo`, the
110 `npm.commands` object has a set of abbreviations as well as the full
111 method names.  Use the `npm.deref` method to find the real name.
112
113 For example:
114
115     var cmd = npm.deref("unp") // cmd === "unpublish"