1NPM-DOCTOR(1) NPM-DOCTOR(1)
2
3
4
6 npm-doctor - Check your environments
7
9 npm doctor
10
12 npm doctor runs a set of checks to ensure that your npm installation
13 has what it needs to manage your JavaScript packages. npm is mostly a
14 standalone tool, but it does have some basic requirements that must be
15 met:
16
17 · Node.js and git must be executable by npm.
18
19 · The primary npm registry, registry.npmjs.com, or another service that
20 uses the registry API, is available.
21
22 · The directories that npm uses, node_modules (both locally and glob‐
23 ally), exist and can be written by the current user.
24
25 · The npm cache exists, and the package tarballs within it aren't cor‐
26 rupt.
27
28
29 Without all of these working properly, npm may not work properly. Many
30 issues are often attributable to things that are outside npm's code
31 base, so npm doctor confirms that the npm installation is in a good
32 state.
33
34 Also, in addition to this, there are also very many issue reports due
35 to using old versions of npm. Since npm is constantly improving, run‐
36 ning npm@latest is better than an old version.
37
38 npm doctor verifies the following items in your environment, and if
39 there are any recommended changes, it will display them.
40
41 npm ping
42 By default, npm installs from the primary npm registry, reg‐
43 istry.npmjs.org. npm doctor hits a special ping endpoint within the
44 registry. This can also be checked with npm ping. If this check fails,
45 you may be using a proxy that needs to be configured, or may need to
46 talk to your IT staff to get access over HTTPS to registry.npmjs.org.
47
48 This check is done against whichever registry you've configured (you
49 can see what that is by running npm config get registry), and if you're
50 using a private registry that doesn't support the /whoami endpoint sup‐
51 ported by the primary registry, this check may fail.
52
53 npm -v
54 While Node.js may come bundled with a particular version of npm, it's
55 the policy of the CLI team that we recommend all users run npm@latest
56 if they can. As the CLI is maintained by a small team of contributors,
57 there are only resources for a single line of development, so npm's own
58 long-term support releases typically only receive critical security and
59 regression fixes. The team believes that the latest tested version of
60 npm is almost always likely to be the most functional and defect-free
61 version of npm.
62
63 node -v
64 For most users, in most circumstances, the best version of Node will be
65 the latest long-term support (LTS) release. Those of you who want
66 access to new ECMAscript features or bleeding-edge changes to Node's
67 standard library may be running a newer version, and some of you may be
68 required to run an older version of Node because of enterprise change
69 control policies. That's OK! But in general, the npm team recommends
70 that most users run Node.js LTS.
71
72 npm config get registry
73 Some of you may be installing from private package registries for your
74 project or company. That's great! Others of you may be following tuto‐
75 rials or StackOverflow questions in an effort to troubleshoot problems
76 you may be having. Sometimes, this may entail changing the registry
77 you're pointing at. This part of npm doctor just lets you, and maybe
78 whoever's helping you with support, know that you're not using the
79 default registry.
80
81 which git
82 While it's documented in the README, it may not be obvious that npm
83 needs Git installed to do many of the things that it does. Also, in
84 some cases – especially on Windows – you may have Git set up in such a
85 way that it's not accessible via your PATH so that npm can find it.
86 This check ensures that Git is available.
87
88 Permissions checks
89 · Your cache must be readable and writable by the user running npm.
90
91 · Global package binaries must be writable by the user running npm.
92
93 · Your local node_modules path, if you're running npm doctor with a
94 project directory, must be readable and writable by the user running
95 npm.
96
97
98 Validate the checksums of cached packages
99 When an npm package is published, the publishing process generates a
100 checksum that npm uses at install time to verify that the package
101 didn't get corrupted in transit. npm doctor uses these checksums to
102 validate the package tarballs in your local cache (you can see where
103 that cache is located with npm config get cache, and see what's in that
104 cache with npm cache ls – probably more than you were expecting!). In
105 the event that there are corrupt packages in your cache, you should
106 probably run npm cache clean and reset the cache.
107
109 · npm help bugs
110
111 · npm help help
112
113 · npm help ping
114
115
116
117
118 April 2019 NPM-DOCTOR(1)