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

NAME

6       npm-doctor - Check the health of your npm environment
7
8   Synopsis
9         npm doctor [ping] [registry] [versions] [environment] [permissions] [cache]
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
22           that 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
28           corrupt.
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. By default npm
42       runs all of these checks. You can limit what checks are ran by specify‐
43       ing them as extra arguments.
44
45   npm ping
46       By   default,   npm  installs  from  the  primary  npm  registry,  reg‐
47       istry.npmjs.org. npm doctor hits a special  ping  endpoint  within  the
48       registry.  This can also be checked with npm ping. If this check fails,
49       you may be using a proxy that needs to be configured, or  may  need  to
50       talk to your IT staff to get access over HTTPS to registry.npmjs.org.
51
52       This  check  is  done against whichever registry you've configured (you
53       can see what that is by running npm config get registry), and if you're
54       using a private registry that doesn't support the /whoami endpoint sup‐
55       ported by the primary registry, this check may fail.
56
57   npm -v
58       While Node.js may come bundled with a particular version of  npm,  it's
59       the  policy  of the CLI team that we recommend all users run npm@latest
60       if they can. As the CLI is maintained by a small team of  contributors,
61       there are only resources for a single line of development, so npm's own
62       long-term support releases typically only receive critical security and
63       regression  fixes.  The team believes that the latest tested version of
64       npm is almost always likely to be the most functional  and  defect-free
65       version of npm.
66
67   node -v
68       For most users, in most circumstances, the best version of Node will be
69       the latest long-term support (LTS) release. Those of you who  want  ac‐
70       cess  to  new  ECMAscript  features  or bleeding-edge changes to Node's
71       standard library may be running a newer version, and some  may  be  re‐
72       quired  to  run  an  older version of Node because of enterprise change
73       control policies. That's OK! But in general, the  npm  team  recommends
74       that most users run Node.js LTS.
75
76   npm config get registry
77       You  may be installing from private package registries for your project
78       or company. That's great! Others may be following tutorials  or  Stack‐
79       Overflow  questions  in  an  effort to troubleshoot problems you may be
80       having. Sometimes, this may entail changing the registry you're  point‐
81       ing  at.  This  part  of  npm doctor just lets you, and maybe whoever's
82       helping you with support, know that you're not using the  default  reg‐
83       istry.
84
85   which git
86       While  it's  documented  in  the README, it may not be obvious that npm
87       needs Git installed to do many of the things that  it  does.  Also,  in
88       some  cases – especially on Windows – you may have Git set up in such a
89       way that it's not accessible via your PATH so that  npm  can  find  it.
90       This check ensures that Git is available.
91
92   Permissions checks
93       •   Your cache must be readable and writable by the user running npm.
94
95       •   Global package binaries must be writable by the user running npm.
96
97       •   Your  local  node_modules path, if you're running npm doctor with a
98           project directory, must be readable and writable by the  user  run‐
99           ning npm.
100
101
102   Validate the checksums of cached packages
103       When  an  npm  package is published, the publishing process generates a
104       checksum that npm uses at install  time  to  verify  that  the  package
105       didn't  get  corrupted  in  transit. npm doctor uses these checksums to
106       validate the package tarballs in your local cache (you  can  see  where
107       that  cache  is  located  with npm config get cache). In the event that
108       there are corrupt packages in your cache, you should probably  run  npm
109       cache clean -f and reset the cache.
110
111   Configuration
112   registry
113       •   Default: "https://registry.npmjs.org/"
114
115       •   Type: URL
116
117
118       The base URL of the npm registry.
119
120   See Also
121       •   npm help bugs
122
123       •   npm help help
124
125       •   npm help ping
126
127
128
129                                 November 2023                   NPM-DOCTOR(1)
Impressum