]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/man/man7/npm-developers.7
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / man / man7 / npm-developers.7
1 .TH "NPM\-DEVELOPERS" "7" "October 2016" "" ""
2 .SH "NAME"
3 \fBnpm-developers\fR \- Developer Guide
4 .SH DESCRIPTION
5 .P
6 So, you've decided to use npm to develop (and maybe publish/deploy)
7 your project\.
8 .P
9 Fantastic!
10 .P
11 There are a few things that you need to do above the simple steps
12 that your users will do to install your program\.
13 .SH About These Documents
14 .P
15 These are man pages\.  If you install npm, you should be able to
16 then do \fBman npm\-thing\fP to get the documentation on a particular
17 topic, or \fBnpm help thing\fP to see the same information\.
18 .SH What is a \fBpackage\fP
19 .P
20 A package is:
21 .RS 0
22 .IP \(bu 2
23 a) a folder containing a program described by a package\.json file
24 .IP \(bu 2
25 b) a gzipped tarball containing (a)
26 .IP \(bu 2
27 c) a url that resolves to (b)
28 .IP \(bu 2
29 d) a \fB<name>@<version>\fP that is published on the registry with (c)
30 .IP \(bu 2
31 e) a \fB<name>@<tag>\fP that points to (d)
32 .IP \(bu 2
33 f) a \fB<name>\fP that has a "latest" tag satisfying (e)
34 .IP \(bu 2
35 g) a \fBgit\fP url that, when cloned, results in (a)\.
36
37 .RE
38 .P
39 Even if you never publish your package, you can still get a lot of
40 benefits of using npm if you just want to write a node program (a), and
41 perhaps if you also want to be able to easily install it elsewhere
42 after packing it up into a tarball (b)\.
43 .P
44 Git urls can be of the form:
45 .P
46 .RS 2
47 .nf
48 git://github\.com/user/project\.git#commit\-ish
49 git+ssh://user@hostname:project\.git#commit\-ish
50 git+http://user@hostname/project/blah\.git#commit\-ish
51 git+https://user@hostname/project/blah\.git#commit\-ish
52 .fi
53 .RE
54 .P
55 The \fBcommit\-ish\fP can be any tag, sha, or branch which can be supplied as
56 an argument to \fBgit checkout\fP\|\.  The default is \fBmaster\fP\|\.
57 .SH The package\.json File
58 .P
59 You need to have a \fBpackage\.json\fP file in the root of your project to do
60 much of anything with npm\.  That is basically the whole interface\.
61 .P
62 See npm help 5 \fBpackage\.json\fP for details about what goes in that file\.  At the very
63 least, you need:
64 .RS 0
65 .IP \(bu 2
66 name:
67 This should be a string that identifies your project\.  Please do not
68 use the name to specify that it runs on node, or is in JavaScript\.
69 You can use the "engines" field to explicitly state the versions of
70 node (or whatever else) that your program requires, and it's pretty
71 well assumed that it's javascript\.
72 It does not necessarily need to match your github repository name\.
73 So, \fBnode\-foo\fP and \fBbar\-js\fP are bad names\.  \fBfoo\fP or \fBbar\fP are better\.
74 .IP \(bu 2
75 version:
76 A semver\-compatible version\.
77 .IP \(bu 2
78 engines:
79 Specify the versions of node (or whatever else) that your program
80 runs on\.  The node API changes a lot, and there may be bugs or new
81 functionality that you depend on\.  Be explicit\.
82 .IP \(bu 2
83 author:
84 Take some credit\.
85 .IP \(bu 2
86 scripts:
87 If you have a special compilation or installation script, then you
88 should put it in the \fBscripts\fP object\.  You should definitely have at
89 least a basic smoke\-test command as the "scripts\.test" field\.
90 See npm help 7 scripts\.
91 .IP \(bu 2
92 main:
93 If you have a single module that serves as the entry point to your
94 program (like what the "foo" package gives you at require("foo")),
95 then you need to specify that in the "main" field\.
96 .IP \(bu 2
97 directories:
98 This is an object mapping names to folders\.  The best ones to include are
99 "lib" and "doc", but if you use "man" to specify a folder full of man pages,
100 they'll get installed just like these ones\.
101
102 .RE
103 .P
104 You can use \fBnpm init\fP in the root of your package in order to get you
105 started with a pretty basic package\.json file\.  See npm help \fBnpm\-init\fP for
106 more info\.
107 .SH Keeping files \fIout\fR of your package
108 .P
109 Use a \fB\|\.npmignore\fP file to keep stuff out of your package\.  If there's
110 no \fB\|\.npmignore\fP file, but there \fIis\fR a \fB\|\.gitignore\fP file, then npm will
111 ignore the stuff matched by the \fB\|\.gitignore\fP file\.  If you \fIwant\fR to
112 include something that is excluded by your \fB\|\.gitignore\fP file, you can
113 create an empty \fB\|\.npmignore\fP file to override it\. Like \fBgit\fP, \fBnpm\fP looks
114 for \fB\|\.npmignore\fP and \fB\|\.gitignore\fP files in all subdirectories of your
115 package, not only the root directory\.
116 .P
117 \fB\|\.npmignore\fP files follow the same pattern rules \fIhttps://git\-scm\.com/book/en/v2/Git\-Basics\-Recording\-Changes\-to\-the\-Repository#Ignoring\-Files\fR
118 as \fB\|\.gitignore\fP files:
119 .RS 0
120 .IP \(bu 2
121 Blank lines or lines starting with \fB#\fP are ignored\.
122 .IP \(bu 2
123 Standard glob patterns work\.
124 .IP \(bu 2
125 You can end patterns with a forward slash \fB/\fP to specify a directory\.
126 .IP \(bu 2
127 You can negate a pattern by starting it with an exclamation point \fB!\fP\|\.
128
129 .RE
130 .P
131 By default, the following paths and files are ignored, so there's no
132 need to add them to \fB\|\.npmignore\fP explicitly:
133 .RS 0
134 .IP \(bu 2
135 \fB\|\.*\.swp\fP
136 .IP \(bu 2
137 \fB\|\._*\fP
138 .IP \(bu 2
139 \fB\|\.DS_Store\fP
140 .IP \(bu 2
141 \fB\|\.git\fP
142 .IP \(bu 2
143 \fB\|\.hg\fP
144 .IP \(bu 2
145 \fB\|\.npmrc\fP
146 .IP \(bu 2
147 \fB\|\.lock\-wscript\fP
148 .IP \(bu 2
149 \fB\|\.svn\fP
150 .IP \(bu 2
151 \fB\|\.wafpickle\-*\fP
152 .IP \(bu 2
153 \fBconfig\.gypi\fP
154 .IP \(bu 2
155 \fBCVS\fP
156 .IP \(bu 2
157 \fBnpm\-debug\.log\fP
158
159 .RE
160 .P
161 Additionally, everything in \fBnode_modules\fP is ignored, except for
162 bundled dependencies\. npm automatically handles this for you, so don't
163 bother adding \fBnode_modules\fP to \fB\|\.npmignore\fP\|\.
164 .P
165 The following paths and files are never ignored, so adding them to
166 \fB\|\.npmignore\fP is pointless:
167 .RS 0
168 .IP \(bu 2
169 \fBpackage\.json\fP
170 .IP \(bu 2
171 \fBREADME\fP (and its variants)
172 .IP \(bu 2
173 \fBCHANGELOG\fP (and its variants)
174 .IP \(bu 2
175 \fBLICENSE\fP / \fBLICENCE\fP
176
177 .RE
178 .SH Link Packages
179 .P
180 \fBnpm link\fP is designed to install a development package and see the
181 changes in real time without having to keep re\-installing it\.  (You do
182 need to either re\-link or \fBnpm rebuild \-g\fP to update compiled packages,
183 of course\.)
184 .P
185 More info at npm help \fBnpm\-link\fP\|\.
186 .SH Before Publishing: Make Sure Your Package Installs and Works
187 .P
188 \fBThis is important\.\fR
189 .P
190 If you can not install it locally, you'll have
191 problems trying to publish it\.  Or, worse yet, you'll be able to
192 publish it, but you'll be publishing a broken or pointless package\.
193 So don't do that\.
194 .P
195 In the root of your package, do this:
196 .P
197 .RS 2
198 .nf
199 npm install \. \-g
200 .fi
201 .RE
202 .P
203 That'll show you that it's working\.  If you'd rather just create a symlink
204 package that points to your working directory, then do this:
205 .P
206 .RS 2
207 .nf
208 npm link
209 .fi
210 .RE
211 .P
212 Use \fBnpm ls \-g\fP to see if it's there\.
213 .P
214 To test a local install, go into some other folder, and then do:
215 .P
216 .RS 2
217 .nf
218 cd \.\./some\-other\-folder
219 npm install \.\./my\-package
220 .fi
221 .RE
222 .P
223 to install it locally into the node_modules folder in that other place\.
224 .P
225 Then go into the node\-repl, and try using require("my\-thing") to
226 bring in your module's main module\.
227 .SH Create a User Account
228 .P
229 Create a user with the adduser command\.  It works like this:
230 .P
231 .RS 2
232 .nf
233 npm adduser
234 .fi
235 .RE
236 .P
237 and then follow the prompts\.
238 .P
239 This is documented better in npm help adduser\.
240 .SH Publish your package
241 .P
242 This part's easy\.  In the root of your folder, do this:
243 .P
244 .RS 2
245 .nf
246 npm publish
247 .fi
248 .RE
249 .P
250 You can give publish a url to a tarball, or a filename of a tarball,
251 or a path to a folder\.
252 .P
253 Note that pretty much \fBeverything in that folder will be exposed\fR
254 by default\.  So, if you have secret stuff in there, use a
255 \fB\|\.npmignore\fP file to list out the globs to ignore, or publish
256 from a fresh checkout\.
257 .SH Brag about it
258 .P
259 Send emails, write blogs, blab in IRC\.
260 .P
261 Tell the world how easy it is to install your program!
262 .SH SEE ALSO
263 .RS 0
264 .IP \(bu 2
265 npm help 7 faq
266 .IP \(bu 2
267 npm help npm
268 .IP \(bu 2
269 npm help init
270 .IP \(bu 2
271 npm help 5 package\.json
272 .IP \(bu 2
273 npm help 7 scripts
274 .IP \(bu 2
275 npm help publish
276 .IP \(bu 2
277 npm help adduser
278 .IP \(bu 2
279 npm help 7 registry
280
281 .RE
282