Simple email application for Android. Original source code: https://framagit.org/dystopia-project/simple-email
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

202 lines
12 KiB

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