11cb0ef41Sopenharmony_ci<!DOCTYPE html><html><head>
21cb0ef41Sopenharmony_ci<meta charset="utf-8">
31cb0ef41Sopenharmony_ci<title>developers</title>
41cb0ef41Sopenharmony_ci<style>
51cb0ef41Sopenharmony_cibody {
61cb0ef41Sopenharmony_ci    background-color: #ffffff;
71cb0ef41Sopenharmony_ci    color: #24292e;
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_ci    margin: 0;
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_ci    line-height: 1.5;
121cb0ef41Sopenharmony_ci
131cb0ef41Sopenharmony_ci    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
141cb0ef41Sopenharmony_ci}
151cb0ef41Sopenharmony_ci#rainbar {
161cb0ef41Sopenharmony_ci    height: 10px;
171cb0ef41Sopenharmony_ci    background-image: linear-gradient(139deg, #fb8817, #ff4b01, #c12127, #e02aff);
181cb0ef41Sopenharmony_ci}
191cb0ef41Sopenharmony_ci
201cb0ef41Sopenharmony_cia {
211cb0ef41Sopenharmony_ci    text-decoration: none;
221cb0ef41Sopenharmony_ci    color: #0366d6;
231cb0ef41Sopenharmony_ci}
241cb0ef41Sopenharmony_cia:hover {
251cb0ef41Sopenharmony_ci    text-decoration: underline;
261cb0ef41Sopenharmony_ci}
271cb0ef41Sopenharmony_ci
281cb0ef41Sopenharmony_cipre {
291cb0ef41Sopenharmony_ci    margin: 1em 0px;
301cb0ef41Sopenharmony_ci    padding: 1em;
311cb0ef41Sopenharmony_ci    border: solid 1px #e1e4e8;
321cb0ef41Sopenharmony_ci    border-radius: 6px;
331cb0ef41Sopenharmony_ci
341cb0ef41Sopenharmony_ci    display: block;
351cb0ef41Sopenharmony_ci    overflow: auto;
361cb0ef41Sopenharmony_ci
371cb0ef41Sopenharmony_ci    white-space: pre;
381cb0ef41Sopenharmony_ci
391cb0ef41Sopenharmony_ci    background-color: #f6f8fa;
401cb0ef41Sopenharmony_ci    color: #393a34;
411cb0ef41Sopenharmony_ci}
421cb0ef41Sopenharmony_cicode {
431cb0ef41Sopenharmony_ci    font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier, monospace;
441cb0ef41Sopenharmony_ci    font-size: 85%;
451cb0ef41Sopenharmony_ci    padding: 0.2em 0.4em;
461cb0ef41Sopenharmony_ci    background-color: #f6f8fa;
471cb0ef41Sopenharmony_ci    color: #393a34;
481cb0ef41Sopenharmony_ci}
491cb0ef41Sopenharmony_cipre > code {
501cb0ef41Sopenharmony_ci    padding: 0;
511cb0ef41Sopenharmony_ci    background-color: inherit;
521cb0ef41Sopenharmony_ci    color: inherit;
531cb0ef41Sopenharmony_ci}
541cb0ef41Sopenharmony_cih1, h2, h3 {
551cb0ef41Sopenharmony_ci    font-weight: 600;
561cb0ef41Sopenharmony_ci}
571cb0ef41Sopenharmony_ci
581cb0ef41Sopenharmony_ci#logobar {
591cb0ef41Sopenharmony_ci    background-color: #333333;
601cb0ef41Sopenharmony_ci    margin: 0 auto;
611cb0ef41Sopenharmony_ci    padding: 1em 4em;
621cb0ef41Sopenharmony_ci}
631cb0ef41Sopenharmony_ci#logobar .logo {
641cb0ef41Sopenharmony_ci    float: left;
651cb0ef41Sopenharmony_ci}
661cb0ef41Sopenharmony_ci#logobar .title {
671cb0ef41Sopenharmony_ci    font-weight: 600;
681cb0ef41Sopenharmony_ci    color: #dddddd;
691cb0ef41Sopenharmony_ci    float: left;
701cb0ef41Sopenharmony_ci    margin: 5px 0 0 1em;
711cb0ef41Sopenharmony_ci}
721cb0ef41Sopenharmony_ci#logobar:after {
731cb0ef41Sopenharmony_ci    content: "";
741cb0ef41Sopenharmony_ci    display: block;
751cb0ef41Sopenharmony_ci    clear: both;
761cb0ef41Sopenharmony_ci}
771cb0ef41Sopenharmony_ci
781cb0ef41Sopenharmony_ci#content {
791cb0ef41Sopenharmony_ci    margin: 0 auto;
801cb0ef41Sopenharmony_ci    padding: 0 4em;
811cb0ef41Sopenharmony_ci}
821cb0ef41Sopenharmony_ci
831cb0ef41Sopenharmony_ci#table_of_contents > h2 {
841cb0ef41Sopenharmony_ci    font-size: 1.17em;
851cb0ef41Sopenharmony_ci}
861cb0ef41Sopenharmony_ci#table_of_contents ul:first-child {
871cb0ef41Sopenharmony_ci    border: solid 1px #e1e4e8;
881cb0ef41Sopenharmony_ci    border-radius: 6px;
891cb0ef41Sopenharmony_ci    padding: 1em;
901cb0ef41Sopenharmony_ci    background-color: #f6f8fa;
911cb0ef41Sopenharmony_ci    color: #393a34;
921cb0ef41Sopenharmony_ci}
931cb0ef41Sopenharmony_ci#table_of_contents ul {
941cb0ef41Sopenharmony_ci    list-style-type: none;
951cb0ef41Sopenharmony_ci    padding-left: 1.5em;
961cb0ef41Sopenharmony_ci}
971cb0ef41Sopenharmony_ci#table_of_contents li {
981cb0ef41Sopenharmony_ci    font-size: 0.9em;
991cb0ef41Sopenharmony_ci}
1001cb0ef41Sopenharmony_ci#table_of_contents li a {
1011cb0ef41Sopenharmony_ci    color: #000000;
1021cb0ef41Sopenharmony_ci}
1031cb0ef41Sopenharmony_ci
1041cb0ef41Sopenharmony_ciheader.title {
1051cb0ef41Sopenharmony_ci    border-bottom: solid 1px #e1e4e8;
1061cb0ef41Sopenharmony_ci}
1071cb0ef41Sopenharmony_ciheader.title > h1 {
1081cb0ef41Sopenharmony_ci    margin-bottom: 0.25em;
1091cb0ef41Sopenharmony_ci}
1101cb0ef41Sopenharmony_ciheader.title > .description {
1111cb0ef41Sopenharmony_ci    display: block;
1121cb0ef41Sopenharmony_ci    margin-bottom: 0.5em;
1131cb0ef41Sopenharmony_ci    line-height: 1;
1141cb0ef41Sopenharmony_ci}
1151cb0ef41Sopenharmony_ci
1161cb0ef41Sopenharmony_cifooter#edit {
1171cb0ef41Sopenharmony_ci    border-top: solid 1px #e1e4e8;
1181cb0ef41Sopenharmony_ci    margin: 3em 0 4em 0;
1191cb0ef41Sopenharmony_ci    padding-top: 2em;
1201cb0ef41Sopenharmony_ci}
1211cb0ef41Sopenharmony_ci</style>
1221cb0ef41Sopenharmony_ci</head>
1231cb0ef41Sopenharmony_ci<body>
1241cb0ef41Sopenharmony_ci<div id="banner">
1251cb0ef41Sopenharmony_ci<div id="rainbar"></div>
1261cb0ef41Sopenharmony_ci<div id="logobar">
1271cb0ef41Sopenharmony_ci<svg class="logo" role="img" height="32" width="32" viewBox="0 0 700 700">
1281cb0ef41Sopenharmony_ci<polygon fill="#cb0000" points="0,700 700,700 700,0 0,0"></polygon>
1291cb0ef41Sopenharmony_ci<polygon fill="#ffffff" points="150,550 350,550 350,250 450,250 450,550 550,550 550,150 150,150"></polygon>
1301cb0ef41Sopenharmony_ci</svg>
1311cb0ef41Sopenharmony_ci<div class="title">
1321cb0ef41Sopenharmony_cinpm command-line interface
1331cb0ef41Sopenharmony_ci</div>
1341cb0ef41Sopenharmony_ci</div>
1351cb0ef41Sopenharmony_ci</div>
1361cb0ef41Sopenharmony_ci
1371cb0ef41Sopenharmony_ci<section id="content">
1381cb0ef41Sopenharmony_ci<header class="title">
1391cb0ef41Sopenharmony_ci<h1 id="developers">developers</h1>
1401cb0ef41Sopenharmony_ci<span class="description">Developer Guide</span>
1411cb0ef41Sopenharmony_ci</header>
1421cb0ef41Sopenharmony_ci
1431cb0ef41Sopenharmony_ci<section id="table_of_contents">
1441cb0ef41Sopenharmony_ci<h2 id="table-of-contents">Table of contents</h2>
1451cb0ef41Sopenharmony_ci<div id="_table_of_contents"><ul><li><a href="#description">Description</a></li><li><a href="#about-these-documents">About These Documents</a></li><li><a href="#what-is-a-package">What is a Package</a></li><li><a href="#the-packagejson-file">The package.json File</a></li><li><a href="#keeping-files-out-of-your-package">Keeping files <em>out</em> of your Package</a></li><ul><li><a href="#testing-whether-your-npmignore-or-files-config-works">Testing whether your <code>.npmignore</code> or <code>files</code> config works</a></li></ul><li><a href="#link-packages">Link Packages</a></li><li><a href="#before-publishing-make-sure-your-package-installs-and-works">Before Publishing: Make Sure Your Package Installs and Works</a></li><li><a href="#create-a-user-account">Create a User Account</a></li><li><a href="#publish-your-package">Publish your Package</a></li><li><a href="#brag-about-it">Brag about it</a></li><li><a href="#see-also">See also</a></li></ul></div>
1461cb0ef41Sopenharmony_ci</section>
1471cb0ef41Sopenharmony_ci
1481cb0ef41Sopenharmony_ci<div id="_content"><h3 id="description">Description</h3>
1491cb0ef41Sopenharmony_ci<p>So, you've decided to use npm to develop (and maybe publish/deploy)
1501cb0ef41Sopenharmony_ciyour project.</p>
1511cb0ef41Sopenharmony_ci<p>Fantastic!</p>
1521cb0ef41Sopenharmony_ci<p>There are a few things that you need to do above the simple steps
1531cb0ef41Sopenharmony_cithat your users will do to install your program.</p>
1541cb0ef41Sopenharmony_ci<h3 id="about-these-documents">About These Documents</h3>
1551cb0ef41Sopenharmony_ci<p>These are man pages.  If you install npm, you should be able to
1561cb0ef41Sopenharmony_cithen do <code>man npm-thing</code> to get the documentation on a particular
1571cb0ef41Sopenharmony_citopic, or <code>npm help thing</code> to see the same information.</p>
1581cb0ef41Sopenharmony_ci<h3 id="what-is-a-package">What is a Package</h3>
1591cb0ef41Sopenharmony_ci<p>A package is:</p>
1601cb0ef41Sopenharmony_ci<ul>
1611cb0ef41Sopenharmony_ci<li>a) a folder containing a program described by a package.json file</li>
1621cb0ef41Sopenharmony_ci<li>b) a gzipped tarball containing (a)</li>
1631cb0ef41Sopenharmony_ci<li>c) a url that resolves to (b)</li>
1641cb0ef41Sopenharmony_ci<li>d) a <code>&lt;name&gt;@&lt;version&gt;</code> that is published on the registry with (c)</li>
1651cb0ef41Sopenharmony_ci<li>e) a <code>&lt;name&gt;@&lt;tag&gt;</code> that points to (d)</li>
1661cb0ef41Sopenharmony_ci<li>f) a <code>&lt;name&gt;</code> that has a "latest" tag satisfying (e)</li>
1671cb0ef41Sopenharmony_ci<li>g) a <code>git</code> url that, when cloned, results in (a).</li>
1681cb0ef41Sopenharmony_ci</ul>
1691cb0ef41Sopenharmony_ci<p>Even if you never publish your package, you can still get a lot of
1701cb0ef41Sopenharmony_cibenefits of using npm if you just want to write a node program (a), and
1711cb0ef41Sopenharmony_ciperhaps if you also want to be able to easily install it elsewhere
1721cb0ef41Sopenharmony_ciafter packing it up into a tarball (b).</p>
1731cb0ef41Sopenharmony_ci<p>Git urls can be of the form:</p>
1741cb0ef41Sopenharmony_ci<pre><code class="language-bash">git://github.com/user/project.git#commit-ish
1751cb0ef41Sopenharmony_cigit+ssh://user@hostname:project.git#commit-ish
1761cb0ef41Sopenharmony_cigit+http://user@hostname/project/blah.git#commit-ish
1771cb0ef41Sopenharmony_cigit+https://user@hostname/project/blah.git#commit-ish
1781cb0ef41Sopenharmony_ci</code></pre>
1791cb0ef41Sopenharmony_ci<p>The <code>commit-ish</code> can be any tag, sha, or branch which can be supplied as
1801cb0ef41Sopenharmony_cian argument to <code>git checkout</code>.  The default is whatever the repository uses
1811cb0ef41Sopenharmony_cias its default branch.</p>
1821cb0ef41Sopenharmony_ci<h3 id="the-packagejson-file">The package.json File</h3>
1831cb0ef41Sopenharmony_ci<p>You need to have a <code>package.json</code> file in the root of your project to do
1841cb0ef41Sopenharmony_cimuch of anything with npm.  That is basically the whole interface.</p>
1851cb0ef41Sopenharmony_ci<p>See <a href="../configuring-npm/package-json.html"><code>package.json</code></a> for details about what
1861cb0ef41Sopenharmony_cigoes in that file.  At the very least, you need:</p>
1871cb0ef41Sopenharmony_ci<ul>
1881cb0ef41Sopenharmony_ci<li>
1891cb0ef41Sopenharmony_ci<p>name: This should be a string that identifies your project.  Please do
1901cb0ef41Sopenharmony_cinot use the name to specify that it runs on node, or is in JavaScript.
1911cb0ef41Sopenharmony_ciYou can use the "engines" field to explicitly state the versions of node
1921cb0ef41Sopenharmony_ci(or whatever else) that your program requires, and it's pretty well
1931cb0ef41Sopenharmony_ciassumed that it's JavaScript.</p>
1941cb0ef41Sopenharmony_ci<p>It does not necessarily need to match your github repository name.</p>
1951cb0ef41Sopenharmony_ci<p>So, <code>node-foo</code> and <code>bar-js</code> are bad names.  <code>foo</code> or <code>bar</code> are better.</p>
1961cb0ef41Sopenharmony_ci</li>
1971cb0ef41Sopenharmony_ci<li>
1981cb0ef41Sopenharmony_ci<p>version: A semver-compatible version.</p>
1991cb0ef41Sopenharmony_ci</li>
2001cb0ef41Sopenharmony_ci<li>
2011cb0ef41Sopenharmony_ci<p>engines: Specify the versions of node (or whatever else) that your
2021cb0ef41Sopenharmony_ciprogram runs on.  The node API changes a lot, and there may be bugs or
2031cb0ef41Sopenharmony_cinew functionality that you depend on.  Be explicit.</p>
2041cb0ef41Sopenharmony_ci</li>
2051cb0ef41Sopenharmony_ci<li>
2061cb0ef41Sopenharmony_ci<p>author: Take some credit.</p>
2071cb0ef41Sopenharmony_ci</li>
2081cb0ef41Sopenharmony_ci<li>
2091cb0ef41Sopenharmony_ci<p>scripts: If you have a special compilation or installation script, then
2101cb0ef41Sopenharmony_ciyou should put it in the <code>scripts</code> object.  You should definitely have at
2111cb0ef41Sopenharmony_cileast a basic smoke-test command as the "scripts.test" field.  See
2121cb0ef41Sopenharmony_ci<a href="../using-npm/scripts.html">scripts</a>.</p>
2131cb0ef41Sopenharmony_ci</li>
2141cb0ef41Sopenharmony_ci<li>
2151cb0ef41Sopenharmony_ci<p>main: If you have a single module that serves as the entry point to your
2161cb0ef41Sopenharmony_ciprogram (like what the "foo" package gives you at require("foo")), then
2171cb0ef41Sopenharmony_ciyou need to specify that in the "main" field.</p>
2181cb0ef41Sopenharmony_ci</li>
2191cb0ef41Sopenharmony_ci<li>
2201cb0ef41Sopenharmony_ci<p>directories: This is an object mapping names to folders.  The best ones
2211cb0ef41Sopenharmony_cito include are "lib" and "doc", but if you use "man" to specify a folder
2221cb0ef41Sopenharmony_cifull of man pages, they'll get installed just like these ones.</p>
2231cb0ef41Sopenharmony_ci</li>
2241cb0ef41Sopenharmony_ci</ul>
2251cb0ef41Sopenharmony_ci<p>You can use <code>npm init</code> in the root of your package in order to get you
2261cb0ef41Sopenharmony_cistarted with a pretty basic package.json file.  See <a href="../commands/npm-init.html"><code>npm init</code></a> for more info.</p>
2271cb0ef41Sopenharmony_ci<h3 id="keeping-files-out-of-your-package">Keeping files <em>out</em> of your Package</h3>
2281cb0ef41Sopenharmony_ci<p>Use a <code>.npmignore</code> file to keep stuff out of your package.  If there's no
2291cb0ef41Sopenharmony_ci<code>.npmignore</code> file, but there <em>is</em> a <code>.gitignore</code> file, then npm will ignore
2301cb0ef41Sopenharmony_cithe stuff matched by the <code>.gitignore</code> file.  If you <em>want</em> to include
2311cb0ef41Sopenharmony_cisomething that is excluded by your <code>.gitignore</code> file, you can create an
2321cb0ef41Sopenharmony_ciempty <code>.npmignore</code> file to override it. Like <code>git</code>, <code>npm</code> looks for
2331cb0ef41Sopenharmony_ci<code>.npmignore</code> and <code>.gitignore</code> files in all subdirectories of your package,
2341cb0ef41Sopenharmony_cinot only the root directory.</p>
2351cb0ef41Sopenharmony_ci<p><code>.npmignore</code> files follow the <a href="https://git-scm.com/book/en/v2/Git-Basics-Recording-Changes-to-the-Repository#_ignoring">same pattern
2361cb0ef41Sopenharmony_cirules</a>
2371cb0ef41Sopenharmony_cias <code>.gitignore</code> files:</p>
2381cb0ef41Sopenharmony_ci<ul>
2391cb0ef41Sopenharmony_ci<li>Blank lines or lines starting with <code>#</code> are ignored.</li>
2401cb0ef41Sopenharmony_ci<li>Standard glob patterns work.</li>
2411cb0ef41Sopenharmony_ci<li>You can end patterns with a forward slash <code>/</code> to specify a directory.</li>
2421cb0ef41Sopenharmony_ci<li>You can negate a pattern by starting it with an exclamation point <code>!</code>.</li>
2431cb0ef41Sopenharmony_ci</ul>
2441cb0ef41Sopenharmony_ci<p>By default, the following paths and files are ignored, so there's no
2451cb0ef41Sopenharmony_cineed to add them to <code>.npmignore</code> explicitly:</p>
2461cb0ef41Sopenharmony_ci<ul>
2471cb0ef41Sopenharmony_ci<li><code>.*.swp</code></li>
2481cb0ef41Sopenharmony_ci<li><code>._*</code></li>
2491cb0ef41Sopenharmony_ci<li><code>.DS_Store</code></li>
2501cb0ef41Sopenharmony_ci<li><code>.git</code></li>
2511cb0ef41Sopenharmony_ci<li><code>.gitignore</code></li>
2521cb0ef41Sopenharmony_ci<li><code>.hg</code></li>
2531cb0ef41Sopenharmony_ci<li><code>.npmignore</code></li>
2541cb0ef41Sopenharmony_ci<li><code>.npmrc</code></li>
2551cb0ef41Sopenharmony_ci<li><code>.lock-wscript</code></li>
2561cb0ef41Sopenharmony_ci<li><code>.svn</code></li>
2571cb0ef41Sopenharmony_ci<li><code>.wafpickle-*</code></li>
2581cb0ef41Sopenharmony_ci<li><code>config.gypi</code></li>
2591cb0ef41Sopenharmony_ci<li><code>CVS</code></li>
2601cb0ef41Sopenharmony_ci<li><code>npm-debug.log</code></li>
2611cb0ef41Sopenharmony_ci</ul>
2621cb0ef41Sopenharmony_ci<p>Additionally, everything in <code>node_modules</code> is ignored, except for
2631cb0ef41Sopenharmony_cibundled dependencies. npm automatically handles this for you, so don't
2641cb0ef41Sopenharmony_cibother adding <code>node_modules</code> to <code>.npmignore</code>.</p>
2651cb0ef41Sopenharmony_ci<p>The following paths and files are never ignored, so adding them to
2661cb0ef41Sopenharmony_ci<code>.npmignore</code> is pointless:</p>
2671cb0ef41Sopenharmony_ci<ul>
2681cb0ef41Sopenharmony_ci<li><code>package.json</code></li>
2691cb0ef41Sopenharmony_ci<li><code>README</code> (and its variants)</li>
2701cb0ef41Sopenharmony_ci<li><code>CHANGELOG</code> (and its variants)</li>
2711cb0ef41Sopenharmony_ci<li><code>LICENSE</code> / <code>LICENCE</code></li>
2721cb0ef41Sopenharmony_ci</ul>
2731cb0ef41Sopenharmony_ci<p>If, given the structure of your project, you find <code>.npmignore</code> to be a
2741cb0ef41Sopenharmony_cimaintenance headache, you might instead try populating the <code>files</code>
2751cb0ef41Sopenharmony_ciproperty of <code>package.json</code>, which is an array of file or directory names
2761cb0ef41Sopenharmony_cithat should be included in your package. Sometimes manually picking
2771cb0ef41Sopenharmony_ciwhich items to allow is easier to manage than building a block list.</p>
2781cb0ef41Sopenharmony_ci<h4 id="testing-whether-your-npmignore-or-files-config-works">Testing whether your <code>.npmignore</code> or <code>files</code> config works</h4>
2791cb0ef41Sopenharmony_ci<p>If you want to double check that your package will include only the files
2801cb0ef41Sopenharmony_ciyou intend it to when published, you can run the <code>npm pack</code> command locally
2811cb0ef41Sopenharmony_ciwhich will generate a tarball in the working directory, the same way it
2821cb0ef41Sopenharmony_cidoes for publishing.</p>
2831cb0ef41Sopenharmony_ci<h3 id="link-packages">Link Packages</h3>
2841cb0ef41Sopenharmony_ci<p><code>npm link</code> is designed to install a development package and see the
2851cb0ef41Sopenharmony_cichanges in real time without having to keep re-installing it.  (You do
2861cb0ef41Sopenharmony_cineed to either re-link or <code>npm rebuild -g</code> to update compiled packages,
2871cb0ef41Sopenharmony_ciof course.)</p>
2881cb0ef41Sopenharmony_ci<p>More info at <a href="../commands/npm-link.html"><code>npm link</code></a>.</p>
2891cb0ef41Sopenharmony_ci<h3 id="before-publishing-make-sure-your-package-installs-and-works">Before Publishing: Make Sure Your Package Installs and Works</h3>
2901cb0ef41Sopenharmony_ci<p><strong>This is important.</strong></p>
2911cb0ef41Sopenharmony_ci<p>If you can not install it locally, you'll have
2921cb0ef41Sopenharmony_ciproblems trying to publish it.  Or, worse yet, you'll be able to
2931cb0ef41Sopenharmony_cipublish it, but you'll be publishing a broken or pointless package.
2941cb0ef41Sopenharmony_ciSo don't do that.</p>
2951cb0ef41Sopenharmony_ci<p>In the root of your package, do this:</p>
2961cb0ef41Sopenharmony_ci<pre><code class="language-bash">npm install . -g
2971cb0ef41Sopenharmony_ci</code></pre>
2981cb0ef41Sopenharmony_ci<p>That'll show you that it's working.  If you'd rather just create a symlink
2991cb0ef41Sopenharmony_cipackage that points to your working directory, then do this:</p>
3001cb0ef41Sopenharmony_ci<pre><code class="language-bash">npm link
3011cb0ef41Sopenharmony_ci</code></pre>
3021cb0ef41Sopenharmony_ci<p>Use <code>npm ls -g</code> to see if it's there.</p>
3031cb0ef41Sopenharmony_ci<p>To test a local install, go into some other folder, and then do:</p>
3041cb0ef41Sopenharmony_ci<pre><code class="language-bash">cd ../some-other-folder
3051cb0ef41Sopenharmony_cinpm install ../my-package
3061cb0ef41Sopenharmony_ci</code></pre>
3071cb0ef41Sopenharmony_ci<p>to install it locally into the node_modules folder in that other place.</p>
3081cb0ef41Sopenharmony_ci<p>Then go into the node-repl, and try using require("my-thing") to
3091cb0ef41Sopenharmony_cibring in your module's main module.</p>
3101cb0ef41Sopenharmony_ci<h3 id="create-a-user-account">Create a User Account</h3>
3111cb0ef41Sopenharmony_ci<p>Create a user with the adduser command.  It works like this:</p>
3121cb0ef41Sopenharmony_ci<pre><code class="language-bash">npm adduser
3131cb0ef41Sopenharmony_ci</code></pre>
3141cb0ef41Sopenharmony_ci<p>and then follow the prompts.</p>
3151cb0ef41Sopenharmony_ci<p>This is documented better in <a href="../commands/npm-adduser.html">npm adduser</a>.</p>
3161cb0ef41Sopenharmony_ci<h3 id="publish-your-package">Publish your Package</h3>
3171cb0ef41Sopenharmony_ci<p>This part's easy.  In the root of your folder, do this:</p>
3181cb0ef41Sopenharmony_ci<pre><code class="language-bash">npm publish
3191cb0ef41Sopenharmony_ci</code></pre>
3201cb0ef41Sopenharmony_ci<p>You can give publish a url to a tarball, or a filename of a tarball,
3211cb0ef41Sopenharmony_cior a path to a folder.</p>
3221cb0ef41Sopenharmony_ci<p>Note that pretty much <strong>everything in that folder will be exposed</strong>
3231cb0ef41Sopenharmony_ciby default.  So, if you have secret stuff in there, use a
3241cb0ef41Sopenharmony_ci<code>.npmignore</code> file to list out the globs to ignore, or publish
3251cb0ef41Sopenharmony_cifrom a fresh checkout.</p>
3261cb0ef41Sopenharmony_ci<h3 id="brag-about-it">Brag about it</h3>
3271cb0ef41Sopenharmony_ci<p>Send emails, write blogs, blab in IRC.</p>
3281cb0ef41Sopenharmony_ci<p>Tell the world how easy it is to install your program!</p>
3291cb0ef41Sopenharmony_ci<h3 id="see-also">See also</h3>
3301cb0ef41Sopenharmony_ci<ul>
3311cb0ef41Sopenharmony_ci<li><a href="../commands/npm.html">npm</a></li>
3321cb0ef41Sopenharmony_ci<li><a href="../commands/npm-init.html">npm init</a></li>
3331cb0ef41Sopenharmony_ci<li><a href="../configuring-npm/package-json.html">package.json</a></li>
3341cb0ef41Sopenharmony_ci<li><a href="../using-npm/scripts.html">npm scripts</a></li>
3351cb0ef41Sopenharmony_ci<li><a href="../commands/npm-publish.html">npm publish</a></li>
3361cb0ef41Sopenharmony_ci<li><a href="../commands/npm-adduser.html">npm adduser</a></li>
3371cb0ef41Sopenharmony_ci<li><a href="../using-npm/registry.html">npm registry</a></li>
3381cb0ef41Sopenharmony_ci</ul></div>
3391cb0ef41Sopenharmony_ci
3401cb0ef41Sopenharmony_ci<footer id="edit">
3411cb0ef41Sopenharmony_ci<a href="https://github.com/npm/cli/edit/latest/docs/content/using-npm/developers.md">
3421cb0ef41Sopenharmony_ci<svg role="img" viewBox="0 0 16 16" width="16" height="16" fill="currentcolor" style="vertical-align: text-bottom; margin-right: 0.3em;">
3431cb0ef41Sopenharmony_ci<path fill-rule="evenodd" d="M11.013 1.427a1.75 1.75 0 012.474 0l1.086 1.086a1.75 1.75 0 010 2.474l-8.61 8.61c-.21.21-.47.364-.756.445l-3.251.93a.75.75 0 01-.927-.928l.929-3.25a1.75 1.75 0 01.445-.758l8.61-8.61zm1.414 1.06a.25.25 0 00-.354 0L10.811 3.75l1.439 1.44 1.263-1.263a.25.25 0 000-.354l-1.086-1.086zM11.189 6.25L9.75 4.81l-6.286 6.287a.25.25 0 00-.064.108l-.558 1.953 1.953-.558a.249.249 0 00.108-.064l6.286-6.286z"></path>
3441cb0ef41Sopenharmony_ci</svg>
3451cb0ef41Sopenharmony_ciEdit this page on GitHub
3461cb0ef41Sopenharmony_ci</a>
3471cb0ef41Sopenharmony_ci</footer>
3481cb0ef41Sopenharmony_ci</section>
3491cb0ef41Sopenharmony_ci
3501cb0ef41Sopenharmony_ci
3511cb0ef41Sopenharmony_ci
3521cb0ef41Sopenharmony_ci</body></html>