11cb0ef41Sopenharmony_ci---
21cb0ef41Sopenharmony_cititle: npm-doctor
31cb0ef41Sopenharmony_cisection: 1
41cb0ef41Sopenharmony_cidescription: Check the health of your npm environment
51cb0ef41Sopenharmony_ci---
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_ci### Synopsis
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_ci```bash
101cb0ef41Sopenharmony_cinpm doctor [ping] [registry] [versions] [environment] [permissions] [cache]
111cb0ef41Sopenharmony_ci```
121cb0ef41Sopenharmony_ci
131cb0ef41Sopenharmony_ciNote: This command is unaware of workspaces.
141cb0ef41Sopenharmony_ci
151cb0ef41Sopenharmony_ci### Description
161cb0ef41Sopenharmony_ci
171cb0ef41Sopenharmony_ci`npm doctor` runs a set of checks to ensure that your npm installation has
181cb0ef41Sopenharmony_ciwhat it needs to manage your JavaScript packages. npm is mostly a
191cb0ef41Sopenharmony_cistandalone tool, but it does have some basic requirements that must be met:
201cb0ef41Sopenharmony_ci
211cb0ef41Sopenharmony_ci+ Node.js and git must be executable by npm.
221cb0ef41Sopenharmony_ci+ The primary npm registry, `registry.npmjs.com`, or another service that
231cb0ef41Sopenharmony_ci  uses the registry API, is available.
241cb0ef41Sopenharmony_ci+ The directories that npm uses, `node_modules` (both locally and
251cb0ef41Sopenharmony_ci  globally), exist and can be written by the current user.
261cb0ef41Sopenharmony_ci+ The npm cache exists, and the package tarballs within it aren't corrupt.
271cb0ef41Sopenharmony_ci
281cb0ef41Sopenharmony_ciWithout all of these working properly, npm may not work properly.  Many
291cb0ef41Sopenharmony_ciissues are often attributable to things that are outside npm's code base,
301cb0ef41Sopenharmony_ciso `npm doctor` confirms that the npm installation is in a good state.
311cb0ef41Sopenharmony_ci
321cb0ef41Sopenharmony_ciAlso, in addition to this, there are also very many issue reports due to
331cb0ef41Sopenharmony_ciusing old versions of npm. Since npm is constantly improving, running
341cb0ef41Sopenharmony_ci`npm@latest` is better than an old version.
351cb0ef41Sopenharmony_ci
361cb0ef41Sopenharmony_ci`npm doctor` verifies the following items in your environment, and if
371cb0ef41Sopenharmony_cithere are any recommended changes, it will display them.  By default npm
381cb0ef41Sopenharmony_ciruns all of these checks. You can limit what checks are ran by
391cb0ef41Sopenharmony_cispecifying them as extra arguments.
401cb0ef41Sopenharmony_ci
411cb0ef41Sopenharmony_ci#### `npm ping`
421cb0ef41Sopenharmony_ci
431cb0ef41Sopenharmony_ciBy default, npm installs from the primary npm registry,
441cb0ef41Sopenharmony_ci`registry.npmjs.org`.  `npm doctor` hits a special ping endpoint within the
451cb0ef41Sopenharmony_ciregistry. This can also be checked with `npm ping`. If this check fails,
461cb0ef41Sopenharmony_ciyou may be using a proxy that needs to be configured, or may need to talk
471cb0ef41Sopenharmony_cito your IT staff to get access over HTTPS to `registry.npmjs.org`.
481cb0ef41Sopenharmony_ci
491cb0ef41Sopenharmony_ciThis check is done against whichever registry you've configured (you can
501cb0ef41Sopenharmony_cisee what that is by running `npm config get registry`), and if you're using
511cb0ef41Sopenharmony_cia private registry that doesn't support the `/whoami` endpoint supported by
521cb0ef41Sopenharmony_cithe primary registry, this check may fail.
531cb0ef41Sopenharmony_ci
541cb0ef41Sopenharmony_ci#### `npm -v`
551cb0ef41Sopenharmony_ci
561cb0ef41Sopenharmony_ciWhile Node.js may come bundled with a particular version of npm, it's the
571cb0ef41Sopenharmony_cipolicy of the CLI team that we recommend all users run `npm@latest` if they
581cb0ef41Sopenharmony_cican. As the CLI is maintained by a small team of contributors, there are
591cb0ef41Sopenharmony_cionly resources for a single line of development, so npm's own long-term
601cb0ef41Sopenharmony_cisupport releases typically only receive critical security and regression
611cb0ef41Sopenharmony_cifixes. The team believes that the latest tested version of npm is almost
621cb0ef41Sopenharmony_cialways likely to be the most functional and defect-free version of npm.
631cb0ef41Sopenharmony_ci
641cb0ef41Sopenharmony_ci#### `node -v`
651cb0ef41Sopenharmony_ci
661cb0ef41Sopenharmony_ciFor most users, in most circumstances, the best version of Node will be the
671cb0ef41Sopenharmony_cilatest long-term support (LTS) release. Those of you who want access to new
681cb0ef41Sopenharmony_ciECMAscript features or bleeding-edge changes to Node's standard library may
691cb0ef41Sopenharmony_cibe running a newer version, and some may be required to run an older
701cb0ef41Sopenharmony_civersion of Node because of enterprise change control policies. That's OK!
711cb0ef41Sopenharmony_ciBut in general, the npm team recommends that most users run Node.js LTS.
721cb0ef41Sopenharmony_ci
731cb0ef41Sopenharmony_ci#### `npm config get registry`
741cb0ef41Sopenharmony_ci
751cb0ef41Sopenharmony_ciYou may be installing from private package registries for your project or
761cb0ef41Sopenharmony_cicompany. That's great! Others may be following tutorials or StackOverflow
771cb0ef41Sopenharmony_ciquestions in an effort to troubleshoot problems you may be having.
781cb0ef41Sopenharmony_ciSometimes, this may entail changing the registry you're pointing at.  This
791cb0ef41Sopenharmony_cipart of `npm doctor` just lets you, and maybe whoever's helping you with
801cb0ef41Sopenharmony_cisupport, know that you're not using the default registry.
811cb0ef41Sopenharmony_ci
821cb0ef41Sopenharmony_ci#### `which git`
831cb0ef41Sopenharmony_ci
841cb0ef41Sopenharmony_ciWhile it's documented in the README, it may not be obvious that npm needs
851cb0ef41Sopenharmony_ciGit installed to do many of the things that it does. Also, in some cases
861cb0ef41Sopenharmony_ci– especially on Windows – you may have Git set up in such a way that it's
871cb0ef41Sopenharmony_cinot accessible via your `PATH` so that npm can find it. This check ensures
881cb0ef41Sopenharmony_cithat Git is available.
891cb0ef41Sopenharmony_ci
901cb0ef41Sopenharmony_ci#### Permissions checks
911cb0ef41Sopenharmony_ci
921cb0ef41Sopenharmony_ci* Your cache must be readable and writable by the user running npm.
931cb0ef41Sopenharmony_ci* Global package binaries must be writable by the user running npm.
941cb0ef41Sopenharmony_ci* Your local `node_modules` path, if you're running `npm doctor` with a
951cb0ef41Sopenharmony_ci  project directory, must be readable and writable by the user running npm.
961cb0ef41Sopenharmony_ci
971cb0ef41Sopenharmony_ci#### Validate the checksums of cached packages
981cb0ef41Sopenharmony_ci
991cb0ef41Sopenharmony_ciWhen an npm package is published, the publishing process generates a
1001cb0ef41Sopenharmony_cichecksum that npm uses at install time to verify that the package didn't
1011cb0ef41Sopenharmony_ciget corrupted in transit. `npm doctor` uses these checksums to validate the
1021cb0ef41Sopenharmony_cipackage tarballs in your local cache (you can see where that cache is
1031cb0ef41Sopenharmony_cilocated with `npm config get cache`). In the event that there are corrupt
1041cb0ef41Sopenharmony_cipackages in your cache, you should probably run `npm cache clean -f` and
1051cb0ef41Sopenharmony_cireset the cache.
1061cb0ef41Sopenharmony_ci
1071cb0ef41Sopenharmony_ci### Configuration
1081cb0ef41Sopenharmony_ci
1091cb0ef41Sopenharmony_ci#### `registry`
1101cb0ef41Sopenharmony_ci
1111cb0ef41Sopenharmony_ci* Default: "https://registry.npmjs.org/"
1121cb0ef41Sopenharmony_ci* Type: URL
1131cb0ef41Sopenharmony_ci
1141cb0ef41Sopenharmony_ciThe base URL of the npm registry.
1151cb0ef41Sopenharmony_ci
1161cb0ef41Sopenharmony_ci
1171cb0ef41Sopenharmony_ci
1181cb0ef41Sopenharmony_ci### See Also
1191cb0ef41Sopenharmony_ci
1201cb0ef41Sopenharmony_ci* [npm bugs](/commands/npm-bugs)
1211cb0ef41Sopenharmony_ci* [npm help](/commands/npm-help)
1221cb0ef41Sopenharmony_ci* [npm ping](/commands/npm-ping)
123