1NPM-DOCTOR(1)                                                    NPM-DOCTOR(1)
2
3
4

NAME

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