]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/html/doc/cli/npm-shrinkwrap.html
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / html / doc / cli / npm-shrinkwrap.html
1 <!doctype html>
2 <html>
3   <title>npm-shrinkwrap</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/cli/npm-shrinkwrap.html">
7   <script async=true src="../../static/toc.js"></script>
8
9   <body>
10     <div id="wrapper">
11
12 <h1><a href="../cli/npm-shrinkwrap.html">npm-shrinkwrap</a></h1> <p>Lock down dependency versions</p>
13 <h2 id="synopsis">SYNOPSIS</h2>
14 <pre><code>npm shrinkwrap
15 </code></pre><h2 id="description">DESCRIPTION</h2>
16 <p>This command locks down the versions of a package&#39;s dependencies so
17 that you can control exactly which versions of each dependency will be
18 used when your package is installed. The <code>package.json</code> file is still
19 required if you want to use <code>npm install</code>.</p>
20 <p>By default, <code>npm install</code> recursively installs the target&#39;s
21 dependencies (as specified in <code>package.json</code>), choosing the latest
22 available version that satisfies the dependency&#39;s semver pattern. In
23 some situations, particularly when shipping software where each change
24 is tightly managed, it&#39;s desirable to fully specify each version of
25 each dependency recursively so that subsequent builds and deploys do
26 not inadvertently pick up newer versions of a dependency that satisfy
27 the semver pattern. Specifying specific semver patterns in each
28 dependency&#39;s <code>package.json</code> would facilitate this, but that&#39;s not always
29 possible or desirable, as when another author owns the npm package.
30 It&#39;s also possible to check dependencies directly into source control,
31 but that may be undesirable for other reasons.</p>
32 <p>As an example, consider package A:</p>
33 <pre><code>{
34   &quot;name&quot;: &quot;A&quot;,
35   &quot;version&quot;: &quot;0.1.0&quot;,
36   &quot;dependencies&quot;: {
37     &quot;B&quot;: &quot;&lt;0.1.0&quot;
38   }
39 }
40 </code></pre><p>package B:</p>
41 <pre><code>{
42   &quot;name&quot;: &quot;B&quot;,
43   &quot;version&quot;: &quot;0.0.1&quot;,
44   &quot;dependencies&quot;: {
45     &quot;C&quot;: &quot;&lt;0.1.0&quot;
46   }
47 }
48 </code></pre><p>and package C:</p>
49 <pre><code>{
50   &quot;name&quot;: &quot;C&quot;,
51   &quot;version&quot;: &quot;0.0.1&quot;
52 }
53 </code></pre><p>If these are the only versions of A, B, and C available in the
54 registry, then a normal <code>npm install A</code> will install:</p>
55 <pre><code>A@0.1.0
56 `-- B@0.0.1
57     `-- C@0.0.1
58 </code></pre><p>However, if B@0.0.2 is published, then a fresh <code>npm install A</code> will
59 install:</p>
60 <pre><code>A@0.1.0
61 `-- B@0.0.2
62     `-- C@0.0.1
63 </code></pre><p>assuming the new version did not modify B&#39;s dependencies. Of course,
64 the new version of B could include a new version of C and any number
65 of new dependencies. If such changes are undesirable, the author of A
66 could specify a dependency on B@0.0.1. However, if A&#39;s author and B&#39;s
67 author are not the same person, there&#39;s no way for A&#39;s author to say
68 that he or she does not want to pull in newly published versions of C
69 when B hasn&#39;t changed at all.</p>
70 <p>In this case, A&#39;s author can run</p>
71 <pre><code>npm shrinkwrap
72 </code></pre><p>This generates <code>npm-shrinkwrap.json</code>, which will look something like this:</p>
73 <pre><code>{
74   &quot;name&quot;: &quot;A&quot;,
75   &quot;version&quot;: &quot;0.1.0&quot;,
76   &quot;dependencies&quot;: {
77     &quot;B&quot;: {
78       &quot;version&quot;: &quot;0.0.1&quot;,
79       &quot;from&quot;: &quot;B@^0.0.1&quot;,
80       &quot;resolved&quot;: &quot;https://registry.npmjs.org/B/-/B-0.0.1.tgz&quot;,
81       &quot;dependencies&quot;: {
82         &quot;C&quot;: {
83           &quot;version&quot;: &quot;0.0.1&quot;,
84           &quot;from&quot;: &quot;org/C#v0.0.1&quot;,
85           &quot;resolved&quot;: &quot;git://github.com/org/C.git#5c380ae319fc4efe9e7f2d9c78b0faa588fd99b4&quot;
86         }
87       }
88     }
89   }
90 }
91 </code></pre><p>The shrinkwrap command has locked down the dependencies based on
92 what&#39;s currently installed in node_modules.  When <code>npm install</code>
93 installs a package with an <code>npm-shrinkwrap.json</code> in the package
94 root, the shrinkwrap file (rather than <code>package.json</code> files) completely
95 drives the installation of that package and all of its dependencies
96 (recursively).  So now the author publishes A@0.1.0, and subsequent
97 installs of this package will use B@0.0.1 and C@0.0.1, regardless the
98 dependencies and versions listed in A&#39;s, B&#39;s, and C&#39;s <code>package.json</code>
99 files.</p>
100 <h3 id="using-shrinkwrapped-packages">Using shrinkwrapped packages</h3>
101 <p>Using a shrinkwrapped package is no different than using any other
102 package: you can <code>npm install</code> it by hand, or add a dependency to your
103 <code>package.json</code> file and <code>npm install</code> it.</p>
104 <h3 id="building-shrinkwrapped-packages">Building shrinkwrapped packages</h3>
105 <p>To shrinkwrap an existing package:</p>
106 <ol>
107 <li>Run <code>npm install</code> in the package root to install the current
108 versions of all dependencies.</li>
109 <li>Validate that the package works as expected with these versions.</li>
110 <li>Run <code>npm shrinkwrap</code>, add <code>npm-shrinkwrap.json</code> to git, and publish
111 your package.</li>
112 </ol>
113 <p>To add or update a dependency in a shrinkwrapped package:</p>
114 <ol>
115 <li>Run <code>npm install</code> in the package root to install the current
116 versions of all dependencies.</li>
117 <li>Add or update dependencies. <code>npm install</code> each new or updated
118 package individually and then update <code>package.json</code>.  Note that they
119 must be explicitly named in order to be installed: running <code>npm
120 install</code> with no arguments will merely reproduce the existing
121 shrinkwrap.</li>
122 <li>Validate that the package works as expected with the new
123 dependencies.</li>
124 <li>Run <code>npm shrinkwrap</code>, commit the new <code>npm-shrinkwrap.json</code>, and
125 publish your package.</li>
126 </ol>
127 <p>You can use <a href="../cli/npm-outdated.html">npm-outdated(1)</a> to view dependencies with newer versions
128 available.</p>
129 <h3 id="other-notes">Other Notes</h3>
130 <p>A shrinkwrap file must be consistent with the package&#39;s <code>package.json</code>
131 file. <code>npm shrinkwrap</code> will fail if required dependencies are not
132 already installed, since that would result in a shrinkwrap that
133 wouldn&#39;t actually work. Similarly, the command will fail if there are
134 extraneous packages (not referenced by <code>package.json</code>), since that would
135 indicate that <code>package.json</code> is not correct.</p>
136 <p>Since <code>npm shrinkwrap</code> is intended to lock down your dependencies for
137 production use, <code>devDependencies</code> will not be included unless you
138 explicitly set the <code>--dev</code> flag when you run <code>npm shrinkwrap</code>.  If
139 installed <code>devDependencies</code> are excluded, then npm will print a
140 warning.  If you want them to be installed with your module by
141 default, please consider adding them to <code>dependencies</code> instead.</p>
142 <p>If shrinkwrapped package A depends on shrinkwrapped package B, B&#39;s
143 shrinkwrap will not be used as part of the installation of A. However,
144 because A&#39;s shrinkwrap is constructed from a valid installation of B
145 and recursively specifies all dependencies, the contents of B&#39;s
146 shrinkwrap will implicitly be included in A&#39;s shrinkwrap.</p>
147 <h3 id="caveats">Caveats</h3>
148 <p>If you wish to lock down the specific bytes included in a package, for
149 example to have 100% confidence in being able to reproduce a
150 deployment or build, then you ought to check your dependencies into
151 source control, or pursue some other mechanism that can verify
152 contents rather than versions.</p>
153 <h2 id="see-also">SEE ALSO</h2>
154 <ul>
155 <li><a href="../cli/npm-install.html">npm-install(1)</a></li>
156 <li><a href="../files/package.json.html">package.json(5)</a></li>
157 <li><a href="../cli/npm-ls.html">npm-ls(1)</a></li>
158 </ul>
159
160 </div>
161
162 <table border=0 cellspacing=0 cellpadding=0 id=npmlogo>
163 <tr><td style="width:180px;height:10px;background:rgb(237,127,127)" colspan=18>&nbsp;</td></tr>
164 <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>
165 <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>
166 <tr><td style="width:10px;height:10px;background:#fff" rowspan=2>&nbsp;</td></tr>
167 <tr><td style="width:10px;height:10px;background:#fff">&nbsp;</td></tr>
168 <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>
169 <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>
170 </table>
171 <p id="footer">npm-shrinkwrap &mdash; npm@2.15.11</p>
172