]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/html/doc/misc/npm-developers.html
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / html / doc / misc / npm-developers.html
1 <!doctype html>
2 <html>
3   <title>npm-developers</title>
4   <meta charset="utf-8">
5   <link rel="stylesheet" type="text/css" href="../../static/style.css">
6   <link rel="canonical" href="https://www.npmjs.org/doc/misc/npm-developers.html">
7   <script async=true src="../../static/toc.js"></script>
8
9   <body>
10     <div id="wrapper">
11
12 <h1><a href="../misc/npm-developers.html">npm-developers</a></h1> <p>Developer Guide</p>
13 <h2 id="description">DESCRIPTION</h2>
14 <p>So, you&#39;ve decided to use npm to develop (and maybe publish/deploy)
15 your project.</p>
16 <p>Fantastic!</p>
17 <p>There are a few things that you need to do above the simple steps
18 that your users will do to install your program.</p>
19 <h2 id="about-these-documents">About These Documents</h2>
20 <p>These are man pages.  If you install npm, you should be able to
21 then do <code>man npm-thing</code> to get the documentation on a particular
22 topic, or <code>npm help thing</code> to see the same information.</p>
23 <h2 id="what-is-a-package-">What is a <code>package</code></h2>
24 <p>A package is:</p>
25 <ul>
26 <li>a) a folder containing a program described by a package.json file</li>
27 <li>b) a gzipped tarball containing (a)</li>
28 <li>c) a url that resolves to (b)</li>
29 <li>d) a <code>&lt;name&gt;@&lt;version&gt;</code> that is published on the registry with (c)</li>
30 <li>e) a <code>&lt;name&gt;@&lt;tag&gt;</code> that points to (d)</li>
31 <li>f) a <code>&lt;name&gt;</code> that has a &quot;latest&quot; tag satisfying (e)</li>
32 <li>g) a <code>git</code> url that, when cloned, results in (a).</li>
33 </ul>
34 <p>Even if you never publish your package, you can still get a lot of
35 benefits of using npm if you just want to write a node program (a), and
36 perhaps if you also want to be able to easily install it elsewhere
37 after packing it up into a tarball (b).</p>
38 <p>Git urls can be of the form:</p>
39 <pre><code>git://github.com/user/project.git#commit-ish
40 git+ssh://user@hostname:project.git#commit-ish
41 git+http://user@hostname/project/blah.git#commit-ish
42 git+https://user@hostname/project/blah.git#commit-ish
43 </code></pre><p>The <code>commit-ish</code> can be any tag, sha, or branch which can be supplied as
44 an argument to <code>git checkout</code>.  The default is <code>master</code>.</p>
45 <h2 id="the-package-json-file">The package.json File</h2>
46 <p>You need to have a <code>package.json</code> file in the root of your project to do
47 much of anything with npm.  That is basically the whole interface.</p>
48 <p>See <code><a href="../files/package.json.html">package.json(5)</a></code> for details about what goes in that file.  At the very
49 least, you need:</p>
50 <ul>
51 <li><p>name:
52 This should be a string that identifies your project.  Please do not
53 use the name to specify that it runs on node, or is in JavaScript.
54 You can use the &quot;engines&quot; field to explicitly state the versions of
55 node (or whatever else) that your program requires, and it&#39;s pretty
56 well assumed that it&#39;s javascript.</p>
57 <p>It does not necessarily need to match your github repository name.</p>
58 <p>So, <code>node-foo</code> and <code>bar-js</code> are bad names.  <code>foo</code> or <code>bar</code> are better.</p>
59 </li>
60 <li><p>version:
61 A semver-compatible version.</p>
62 </li>
63 <li><p>engines:
64 Specify the versions of node (or whatever else) that your program
65 runs on.  The node API changes a lot, and there may be bugs or new
66 functionality that you depend on.  Be explicit.</p>
67 </li>
68 <li><p>author:
69 Take some credit.</p>
70 </li>
71 <li><p>scripts:
72 If you have a special compilation or installation script, then you
73 should put it in the <code>scripts</code> object.  You should definitely have at
74 least a basic smoke-test command as the &quot;scripts.test&quot; field.
75 See <a href="../misc/npm-scripts.html">npm-scripts(7)</a>.</p>
76 </li>
77 <li><p>main:
78 If you have a single module that serves as the entry point to your
79 program (like what the &quot;foo&quot; package gives you at require(&quot;foo&quot;)),
80 then you need to specify that in the &quot;main&quot; field.</p>
81 </li>
82 <li><p>directories:
83 This is an object mapping names to folders.  The best ones to include are
84 &quot;lib&quot; and &quot;doc&quot;, but if you use &quot;man&quot; to specify a folder full of man pages,
85 they&#39;ll get installed just like these ones.</p>
86 </li>
87 </ul>
88 <p>You can use <code>npm init</code> in the root of your package in order to get you
89 started with a pretty basic package.json file.  See <code><a href="../cli/npm-init.html">npm-init(1)</a></code> for
90 more info.</p>
91 <h2 id="keeping-files-out-of-your-package">Keeping files <em>out</em> of your package</h2>
92 <p>Use a <code>.npmignore</code> file to keep stuff out of your package.  If there&#39;s
93 no <code>.npmignore</code> file, but there <em>is</em> a <code>.gitignore</code> file, then npm will
94 ignore the stuff matched by the <code>.gitignore</code> file.  If you <em>want</em> to
95 include something that is excluded by your <code>.gitignore</code> file, you can
96 create an empty <code>.npmignore</code> file to override it. Like <code>git</code>, <code>npm</code> looks
97 for <code>.npmignore</code> and <code>.gitignore</code> files in all subdirectories of your
98 package, not only the root directory.</p>
99 <p><code>.npmignore</code> files follow the <a href="https://git-scm.com/book/en/v2/Git-Basics-Recording-Changes-to-the-Repository#Ignoring-Files">same pattern rules</a>
100 as <code>.gitignore</code> files:</p>
101 <ul>
102 <li>Blank lines or lines starting with <code>#</code> are ignored.</li>
103 <li>Standard glob patterns work.</li>
104 <li>You can end patterns with a forward slash <code>/</code> to specify a directory.</li>
105 <li>You can negate a pattern by starting it with an exclamation point <code>!</code>.</li>
106 </ul>
107 <p>By default, the following paths and files are ignored, so there&#39;s no
108 need to add them to <code>.npmignore</code> explicitly:</p>
109 <ul>
110 <li><code>.*.swp</code></li>
111 <li><code>._*</code></li>
112 <li><code>.DS_Store</code></li>
113 <li><code>.git</code></li>
114 <li><code>.hg</code></li>
115 <li><code>.npmrc</code></li>
116 <li><code>.lock-wscript</code></li>
117 <li><code>.svn</code></li>
118 <li><code>.wafpickle-*</code></li>
119 <li><code>config.gypi</code></li>
120 <li><code>CVS</code></li>
121 <li><code>npm-debug.log</code></li>
122 </ul>
123 <p>Additionally, everything in <code>node_modules</code> is ignored, except for
124 bundled dependencies. npm automatically handles this for you, so don&#39;t
125 bother adding <code>node_modules</code> to <code>.npmignore</code>.</p>
126 <p>The following paths and files are never ignored, so adding them to
127 <code>.npmignore</code> is pointless:</p>
128 <ul>
129 <li><code>package.json</code></li>
130 <li><code><a href="../../doc/README.html">README</a></code> (and its variants)</li>
131 <li><code>CHANGELOG</code> (and its variants)</li>
132 <li><code>LICENSE</code> / <code>LICENCE</code></li>
133 </ul>
134 <h2 id="link-packages">Link Packages</h2>
135 <p><code>npm link</code> is designed to install a development package and see the
136 changes in real time without having to keep re-installing it.  (You do
137 need to either re-link or <code>npm rebuild -g</code> to update compiled packages,
138 of course.)</p>
139 <p>More info at <code><a href="../cli/npm-link.html">npm-link(1)</a></code>.</p>
140 <h2 id="before-publishing-make-sure-your-package-installs-and-works">Before Publishing: Make Sure Your Package Installs and Works</h2>
141 <p><strong>This is important.</strong></p>
142 <p>If you can not install it locally, you&#39;ll have
143 problems trying to publish it.  Or, worse yet, you&#39;ll be able to
144 publish it, but you&#39;ll be publishing a broken or pointless package.
145 So don&#39;t do that.</p>
146 <p>In the root of your package, do this:</p>
147 <pre><code>npm install . -g
148 </code></pre><p>That&#39;ll show you that it&#39;s working.  If you&#39;d rather just create a symlink
149 package that points to your working directory, then do this:</p>
150 <pre><code>npm link
151 </code></pre><p>Use <code>npm ls -g</code> to see if it&#39;s there.</p>
152 <p>To test a local install, go into some other folder, and then do:</p>
153 <pre><code>cd ../some-other-folder
154 npm install ../my-package
155 </code></pre><p>to install it locally into the node_modules folder in that other place.</p>
156 <p>Then go into the node-repl, and try using require(&quot;my-thing&quot;) to
157 bring in your module&#39;s main module.</p>
158 <h2 id="create-a-user-account">Create a User Account</h2>
159 <p>Create a user with the adduser command.  It works like this:</p>
160 <pre><code>npm adduser
161 </code></pre><p>and then follow the prompts.</p>
162 <p>This is documented better in <a href="../cli/npm-adduser.html">npm-adduser(1)</a>.</p>
163 <h2 id="publish-your-package">Publish your package</h2>
164 <p>This part&#39;s easy.  In the root of your folder, do this:</p>
165 <pre><code>npm publish
166 </code></pre><p>You can give publish a url to a tarball, or a filename of a tarball,
167 or a path to a folder.</p>
168 <p>Note that pretty much <strong>everything in that folder will be exposed</strong>
169 by default.  So, if you have secret stuff in there, use a
170 <code>.npmignore</code> file to list out the globs to ignore, or publish
171 from a fresh checkout.</p>
172 <h2 id="brag-about-it">Brag about it</h2>
173 <p>Send emails, write blogs, blab in IRC.</p>
174 <p>Tell the world how easy it is to install your program!</p>
175 <h2 id="see-also">SEE ALSO</h2>
176 <ul>
177 <li><a href="../misc/npm-faq.html">npm-faq(7)</a></li>
178 <li><a href="../cli/npm.html">npm(1)</a></li>
179 <li><a href="../cli/npm-init.html">npm-init(1)</a></li>
180 <li><a href="../files/package.json.html">package.json(5)</a></li>
181 <li><a href="../misc/npm-scripts.html">npm-scripts(7)</a></li>
182 <li><a href="../cli/npm-publish.html">npm-publish(1)</a></li>
183 <li><a href="../cli/npm-adduser.html">npm-adduser(1)</a></li>
184 <li><a href="../misc/npm-registry.html">npm-registry(7)</a></li>
185 </ul>
186
187 </div>
188
189 <table border=0 cellspacing=0 cellpadding=0 id=npmlogo>
190 <tr><td style="width:180px;height:10px;background:rgb(237,127,127)" colspan=18>&nbsp;</td></tr>
191 <tr><td rowspan=4 style="width:10px;height:10px;background:rgb(237,127,127)">&nbsp;</td><td style="width:40px;height:10px;background:#fff" colspan=4>&nbsp;</td><td style="width:10px;height:10px;background:rgb(237,127,127)" rowspan=4>&nbsp;</td><td style="width:40px;height:10px;background:#fff" colspan=4>&nbsp;</td><td rowspan=4 style="width:10px;height:10px;background:rgb(237,127,127)">&nbsp;</td><td colspan=6 style="width:60px;height:10px;background:#fff">&nbsp;</td><td style="width:10px;height:10px;background:rgb(237,127,127)" rowspan=4>&nbsp;</td></tr>
192 <tr><td colspan=2 style="width:20px;height:30px;background:#fff" rowspan=3>&nbsp;</td><td style="width:10px;height:10px;background:rgb(237,127,127)" rowspan=3>&nbsp;</td><td style="width:10px;height:10px;background:#fff" rowspan=3>&nbsp;</td><td style="width:20px;height:10px;background:#fff" rowspan=4 colspan=2>&nbsp;</td><td style="width:10px;height:20px;background:rgb(237,127,127)" rowspan=2>&nbsp;</td><td style="width:10px;height:10px;background:#fff" rowspan=3>&nbsp;</td><td style="width:20px;height:10px;background:#fff" rowspan=3 colspan=2>&nbsp;</td><td style="width:10px;height:10px;background:rgb(237,127,127)" rowspan=3>&nbsp;</td><td style="width:10px;height:10px;background:#fff" rowspan=3>&nbsp;</td><td style="width:10px;height:10px;background:rgb(237,127,127)" rowspan=3>&nbsp;</td></tr>
193 <tr><td style="width:10px;height:10px;background:#fff" rowspan=2>&nbsp;</td></tr>
194 <tr><td style="width:10px;height:10px;background:#fff">&nbsp;</td></tr>
195 <tr><td style="width:60px;height:10px;background:rgb(237,127,127)" colspan=6>&nbsp;</td><td colspan=10 style="width:10px;height:10px;background:rgb(237,127,127)">&nbsp;</td></tr>
196 <tr><td colspan=5 style="width:50px;height:10px;background:#fff">&nbsp;</td><td style="width:40px;height:10px;background:rgb(237,127,127)" colspan=4>&nbsp;</td><td style="width:90px;height:10px;background:#fff" colspan=9>&nbsp;</td></tr>
197 </table>
198 <p id="footer">npm-developers &mdash; npm@2.15.11</p>
199