1 .\" Generated with Ronnjs 0.3.8
2 .\" http://github.com/kapouer/ronnjs/
4 .TH "NPM\-DEVELOPERS" "7" "November 2013" "" ""
7 \fBnpm-developers\fR \-\- Developer Guide
10 So, you\'ve decided to use npm to develop (and maybe publish/deploy)
17 There are a few things that you need to do above the simple steps
18 that your users will do to install your program\.
20 .SH "About These Documents"
21 These are man pages\. If you install npm, you should be able to
22 then do \fBman npm\-thing\fR to get the documentation on a particular
23 topic, or \fBnpm help thing\fR to see the same information\.
29 a) a folder containing a program described by a package\.json file
32 b) a gzipped tarball containing (a)
35 c) a url that resolves to (b)
38 d) a \fB<name>@<version>\fR that is published on the registry with (c)
41 e) a \fB<name>@<tag>\fR that points to (d)
44 f) a \fB<name>\fR that has a "latest" tag satisfying (e)
47 g) a \fBgit\fR url that, when cloned, results in (a)\.
52 Even if you never publish your package, you can still get a lot of
53 benefits of using npm if you just want to write a node program (a), and
54 perhaps if you also want to be able to easily install it elsewhere
55 after packing it up into a tarball (b)\.
58 Git urls can be of the form:
63 git://github\.com/user/project\.git#commit\-ish
64 git+ssh://user@hostname:project\.git#commit\-ish
65 git+http://user@hostname/project/blah\.git#commit\-ish
66 git+https://user@hostname/project/blah\.git#commit\-ish
73 The \fBcommit\-ish\fR can be any tag, sha, or branch which can be supplied as
74 an argument to \fBgit checkout\fR\|\. The default is \fBmaster\fR\|\.
76 .SH "The package\.json File"
77 You need to have a \fBpackage\.json\fR file in the root of your project to do
78 much of anything with npm\. That is basically the whole interface\.
81 npm help See \fBpackage\.json\fR for details about what goes in that file\. At the very
86 This should be a string that identifies your project\. Please do not
87 use the name to specify that it runs on node, or is in JavaScript\.
88 You can use the "engines" field to explicitly state the versions of
89 node (or whatever else) that your program requires, and it\'s pretty
90 well assumed that it\'s javascript\.
93 It does not necessarily need to match your github repository name\.
96 So, \fBnode\-foo\fR and \fBbar\-js\fR are bad names\. \fBfoo\fR or \fBbar\fR are better\.
100 A semver\-compatible version\.
104 Specify the versions of node (or whatever else) that your program
105 runs on\. The node API changes a lot, and there may be bugs or new
106 functionality that you depend on\. Be explicit\.
114 If you have a special compilation or installation script, then you
115 should put it in the \fBscripts\fR hash\. You should definitely have at
116 least a basic smoke\-test command as the "scripts\.test" field\.
117 npm help See npm\-scripts\.
121 If you have a single module that serves as the entry point to your
122 program (like what the "foo" package gives you at require("foo")),
123 then you need to specify that in the "main" field\.
127 This is a hash of folders\. The best ones to include are "lib" and
128 "doc", but if you specify a folder full of man pages in "man", then
129 they\'ll get installed just like these ones\.
134 You can use \fBnpm init\fR in the root of your package in order to get you
135 npm help started with a pretty basic package\.json file\. See \fBnpm\-init\fR for
139 Use a \fB\|\.npmignore\fR file to keep stuff out of your package\. If there\'s
140 no \fB\|\.npmignore\fR file, but there \fIis\fR a \fB\|\.gitignore\fR file, then npm will
141 ignore the stuff matched by the \fB\|\.gitignore\fR file\. If you \fIwant\fR to
142 include something that is excluded by your \fB\|\.gitignore\fR file, you can
143 create an empty \fB\|\.npmignore\fR file to override it\.
146 By default, the following paths and files are ignored, so there\'s no
147 need to add them to \fB\|\.npmignore\fR explicitly:
165 \fB\|\.lock\-wscript\fR
171 \fB\|\.wafpickle\-*\fR
177 \fBnpm\-debug\.log\fR
182 Additionally, everything in \fBnode_modules\fR is ignored, except for
183 bundled dependencies\. npm automatically handles this for you, so don\'t
184 bother adding \fBnode_modules\fR to \fB\|\.npmignore\fR\|\.
187 The following paths and files are never ignored, so adding them to \fB\|\.npmignore\fR is pointless:
198 \fBnpm link\fR is designed to install a development package and see the
199 changes in real time without having to keep re\-installing it\. (You do
200 need to either re\-link or \fBnpm rebuild \-g\fR to update compiled packages,
204 npm help More info at \fBnpm\-link\fR\|\.
206 .SH "Before Publishing: Make Sure Your Package Installs and Works"
207 \fBThis is important\.\fR
210 If you can not install it locally, you\'ll have
211 problems trying to publish it\. Or, worse yet, you\'ll be able to
212 publish it, but you\'ll be publishing a broken or pointless package\.
216 In the root of your package, do this:
228 That\'ll show you that it\'s working\. If you\'d rather just create a symlink
229 package that points to your working directory, then do this:
241 Use \fBnpm ls \-g\fR to see if it\'s there\.
244 To test a local install, go into some other folder, and then do:
249 cd \.\./some\-other\-folder
250 npm install \.\./my\-package
257 to install it locally into the node_modules folder in that other place\.
260 Then go into the node\-repl, and try using require("my\-thing") to
261 bring in your module\'s main module\.
263 .SH "Create a User Account"
264 Create a user with the adduser command\. It works like this:
276 and then follow the prompts\.
279 npm help This is documented better in npm\-adduser\.
281 .SH "Publish your package"
282 This part\'s easy\. IN the root of your folder, do this:
294 You can give publish a url to a tarball, or a filename of a tarball,
295 or a path to a folder\.
298 Note that pretty much \fBeverything in that folder will be exposed\fR
299 by default\. So, if you have secret stuff in there, use a \fB\|\.npmignore\fR file to list out the globs to ignore, or publish
300 from a fresh checkout\.
303 Send emails, write blogs, blab in IRC\.
306 Tell the world how easy it is to install your program!
320 npm help package\.json