• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<!DOCTYPE html><html><head>
2<meta charset="utf-8">
3<title>npm-doctor</title>
4<style>
5body {
6    background-color: #ffffff;
7    color: #24292e;
8
9    margin: 0;
10
11    line-height: 1.5;
12
13    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
14}
15#rainbar {
16    height: 10px;
17    background-image: linear-gradient(139deg, #fb8817, #ff4b01, #c12127, #e02aff);
18}
19
20a {
21    text-decoration: none;
22    color: #0366d6;
23}
24a:hover {
25    text-decoration: underline;
26}
27
28pre {
29    margin: 1em 0px;
30    padding: 1em;
31    border: solid 1px #e1e4e8;
32    border-radius: 6px;
33
34    display: block;
35    overflow: auto;
36
37    white-space: pre;
38
39    background-color: #f6f8fa;
40    color: #393a34;
41}
42code {
43    font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier, monospace;
44    font-size: 85%;
45    padding: 0.2em 0.4em;
46    background-color: #f6f8fa;
47    color: #393a34;
48}
49pre > code {
50    padding: 0;
51    background-color: inherit;
52    color: inherit;
53}
54h1, h2, h3 {
55    font-weight: 600;
56}
57
58#logobar {
59    background-color: #333333;
60    margin: 0 auto;
61    padding: 1em 4em;
62}
63#logobar .logo {
64    float: left;
65}
66#logobar .title {
67    font-weight: 600;
68    color: #dddddd;
69    float: left;
70    margin: 5px 0 0 1em;
71}
72#logobar:after {
73    content: "";
74    display: block;
75    clear: both;
76}
77
78#content {
79    margin: 0 auto;
80    padding: 0 4em;
81}
82
83#table_of_contents > h2 {
84    font-size: 1.17em;
85}
86#table_of_contents ul:first-child {
87    border: solid 1px #e1e4e8;
88    border-radius: 6px;
89    padding: 1em;
90    background-color: #f6f8fa;
91    color: #393a34;
92}
93#table_of_contents ul {
94    list-style-type: none;
95    padding-left: 1.5em;
96}
97#table_of_contents li {
98    font-size: 0.9em;
99}
100#table_of_contents li a {
101    color: #000000;
102}
103
104header.title {
105    border-bottom: solid 1px #e1e4e8;
106}
107header.title > h1 {
108    margin-bottom: 0.25em;
109}
110header.title > .description {
111    display: block;
112    margin-bottom: 0.5em;
113    line-height: 1;
114}
115
116footer#edit {
117    border-top: solid 1px #e1e4e8;
118    margin: 3em 0 4em 0;
119    padding-top: 2em;
120}
121</style>
122</head>
123<body>
124<div id="banner">
125<div id="rainbar"></div>
126<div id="logobar">
127<svg class="logo" role="img" height="32" width="32" viewBox="0 0 700 700">
128<polygon fill="#cb0000" points="0,700 700,700 700,0 0,0"></polygon>
129<polygon fill="#ffffff" points="150,550 350,550 350,250 450,250 450,550 550,550 550,150 150,150"></polygon>
130</svg>
131<div class="title">
132npm command-line interface
133</div>
134</div>
135</div>
136
137<section id="content">
138<header class="title">
139<h1 id="npm-doctor">npm-doctor</h1>
140<span class="description">Check the health of your npm environment</span>
141</header>
142
143<section id="table_of_contents">
144<h2 id="table-of-contents">Table of contents</h2>
145<div id="_table_of_contents"><ul><li><a href="#synopsis">Synopsis</a></li><li><a href="#description">Description</a></li><ul><li><a href="#npm-ping"><code>npm ping</code></a></li><li><a href="#npm--v"><code>npm -v</code></a></li><li><a href="#node--v"><code>node -v</code></a></li><li><a href="#npm-config-get-registry"><code>npm config get registry</code></a></li><li><a href="#which-git"><code>which git</code></a></li><li><a href="#permissions-checks">Permissions checks</a></li><li><a href="#validate-the-checksums-of-cached-packages">Validate the checksums of cached packages</a></li></ul><li><a href="#configuration">Configuration</a></li><ul><li><a href="#registry"><code>registry</code></a></li></ul><li><a href="#see-also">See Also</a></li></ul></div>
146</section>
147
148<div id="_content"><h3 id="synopsis">Synopsis</h3>
149<pre><code class="language-bash">npm doctor [ping] [registry] [versions] [environment] [permissions] [cache]
150</code></pre>
151<p>Note: This command is unaware of workspaces.</p>
152<h3 id="description">Description</h3>
153<p><code>npm doctor</code> runs a set of checks to ensure that your npm installation has
154what it needs to manage your JavaScript packages. npm is mostly a
155standalone tool, but it does have some basic requirements that must be met:</p>
156<ul>
157<li>Node.js and git must be executable by npm.</li>
158<li>The primary npm registry, <code>registry.npmjs.com</code>, or another service that
159uses the registry API, is available.</li>
160<li>The directories that npm uses, <code>node_modules</code> (both locally and
161globally), exist and can be written by the current user.</li>
162<li>The npm cache exists, and the package tarballs within it aren't corrupt.</li>
163</ul>
164<p>Without all of these working properly, npm may not work properly.  Many
165issues are often attributable to things that are outside npm's code base,
166so <code>npm doctor</code> confirms that the npm installation is in a good state.</p>
167<p>Also, in addition to this, there are also very many issue reports due to
168using old versions of npm. Since npm is constantly improving, running
169<code>npm@latest</code> is better than an old version.</p>
170<p><code>npm doctor</code> verifies the following items in your environment, and if
171there are any recommended changes, it will display them.  By default npm
172runs all of these checks. You can limit what checks are ran by
173specifying them as extra arguments.</p>
174<h4 id="npm-ping"><code>npm ping</code></h4>
175<p>By default, npm installs from the primary npm registry,
176<code>registry.npmjs.org</code>.  <code>npm doctor</code> hits a special ping endpoint within the
177registry. This can also be checked with <code>npm ping</code>. If this check fails,
178you may be using a proxy that needs to be configured, or may need to talk
179to your IT staff to get access over HTTPS to <code>registry.npmjs.org</code>.</p>
180<p>This check is done against whichever registry you've configured (you can
181see what that is by running <code>npm config get registry</code>), and if you're using
182a private registry that doesn't support the <code>/whoami</code> endpoint supported by
183the primary registry, this check may fail.</p>
184<h4 id="npm--v"><code>npm -v</code></h4>
185<p>While Node.js may come bundled with a particular version of npm, it's the
186policy of the CLI team that we recommend all users run <code>npm@latest</code> if they
187can. As the CLI is maintained by a small team of contributors, there are
188only resources for a single line of development, so npm's own long-term
189support releases typically only receive critical security and regression
190fixes. The team believes that the latest tested version of npm is almost
191always likely to be the most functional and defect-free version of npm.</p>
192<h4 id="node--v"><code>node -v</code></h4>
193<p>For most users, in most circumstances, the best version of Node will be the
194latest long-term support (LTS) release. Those of you who want access to new
195ECMAscript features or bleeding-edge changes to Node's standard library may
196be running a newer version, and some may be required to run an older
197version of Node because of enterprise change control policies. That's OK!
198But in general, the npm team recommends that most users run Node.js LTS.</p>
199<h4 id="npm-config-get-registry"><code>npm config get registry</code></h4>
200<p>You may be installing from private package registries for your project or
201company. That's great! Others may be following tutorials or StackOverflow
202questions in an effort to troubleshoot problems you may be having.
203Sometimes, this may entail changing the registry you're pointing at.  This
204part of <code>npm doctor</code> just lets you, and maybe whoever's helping you with
205support, know that you're not using the default registry.</p>
206<h4 id="which-git"><code>which git</code></h4>
207<p>While it's documented in the README, it may not be obvious that npm needs
208Git installed to do many of the things that it does. Also, in some cases
209–&nbsp;especially on Windows –&nbsp;you may have Git set up in such a way that it's
210not accessible via your <code>PATH</code> so that npm can find it. This check ensures
211that Git is available.</p>
212<h4 id="permissions-checks">Permissions checks</h4>
213<ul>
214<li>Your cache must be readable and writable by the user running npm.</li>
215<li>Global package binaries must be writable by the user running npm.</li>
216<li>Your local <code>node_modules</code> path, if you're running <code>npm doctor</code> with a
217project directory, must be readable and writable by the user running npm.</li>
218</ul>
219<h4 id="validate-the-checksums-of-cached-packages">Validate the checksums of cached packages</h4>
220<p>When an npm package is published, the publishing process generates a
221checksum that npm uses at install time to verify that the package didn't
222get corrupted in transit. <code>npm doctor</code> uses these checksums to validate the
223package tarballs in your local cache (you can see where that cache is
224located with <code>npm config get cache</code>). In the event that there are corrupt
225packages in your cache, you should probably run <code>npm cache clean -f</code> and
226reset the cache.</p>
227<h3 id="configuration">Configuration</h3>
228<h4 id="registry"><code>registry</code></h4>
229<ul>
230<li>Default: "<a href="https://registry.npmjs.org/">https://registry.npmjs.org/</a>"</li>
231<li>Type: URL</li>
232</ul>
233<p>The base URL of the npm registry.</p>
234<h3 id="see-also">See Also</h3>
235<ul>
236<li><a href="../commands/npm-bugs.html">npm bugs</a></li>
237<li><a href="../commands/npm-help.html">npm help</a></li>
238<li><a href="../commands/npm-ping.html">npm ping</a></li>
239</ul></div>
240
241<footer id="edit">
242<a href="https://github.com/npm/cli/edit/latest/docs/content/commands/npm-doctor.md">
243<svg role="img" viewBox="0 0 16 16" width="16" height="16" fill="currentcolor" style="vertical-align: text-bottom; margin-right: 0.3em;">
244<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>
245</svg>
246Edit this page on GitHub
247</a>
248</footer>
249</section>
250
251
252
253</body></html>