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