1--- 2title: npm-doctor 3section: 1 4description: Check the health of your npm environment 5--- 6 7### Synopsis 8 9```bash 10npm doctor [ping] [registry] [versions] [environment] [permissions] [cache] 11``` 12 13Note: This command is unaware of workspaces. 14 15### Description 16 17`npm doctor` runs a set of checks to ensure that your npm installation has 18what it needs to manage your JavaScript packages. npm is mostly a 19standalone tool, but it does have some basic requirements that must be met: 20 21+ Node.js and git must be executable by npm. 22+ The primary npm registry, `registry.npmjs.com`, or another service that 23 uses the registry API, is available. 24+ The directories that npm uses, `node_modules` (both locally and 25 globally), exist and can be written by the current user. 26+ The npm cache exists, and the package tarballs within it aren't corrupt. 27 28Without all of these working properly, npm may not work properly. Many 29issues are often attributable to things that are outside npm's code base, 30so `npm doctor` confirms that the npm installation is in a good state. 31 32Also, in addition to this, there are also very many issue reports due to 33using old versions of npm. Since npm is constantly improving, running 34`npm@latest` is better than an old version. 35 36`npm doctor` verifies the following items in your environment, and if 37there are any recommended changes, it will display them. By default npm 38runs all of these checks. You can limit what checks are ran by 39specifying them as extra arguments. 40 41#### `npm ping` 42 43By default, npm installs from the primary npm registry, 44`registry.npmjs.org`. `npm doctor` hits a special ping endpoint within the 45registry. This can also be checked with `npm ping`. If this check fails, 46you may be using a proxy that needs to be configured, or may need to talk 47to your IT staff to get access over HTTPS to `registry.npmjs.org`. 48 49This check is done against whichever registry you've configured (you can 50see what that is by running `npm config get registry`), and if you're using 51a private registry that doesn't support the `/whoami` endpoint supported by 52the primary 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 59only resources for a single line of development, so npm's own long-term 60support releases typically only receive critical security and regression 61fixes. The team believes that the latest tested version of npm is almost 62always likely to be 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 69be running a newer version, and some may be required to run an older 70version of Node because of enterprise change control policies. That's OK! 71But in general, the npm team recommends that most users run Node.js LTS. 72 73#### `npm config get registry` 74 75You may be installing from private package registries for your project or 76company. That's great! Others may be following tutorials or StackOverflow 77questions in an effort to troubleshoot problems you may be having. 78Sometimes, this may entail changing the registry you're pointing at. This 79part 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 85Git installed 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 87not accessible via your `PATH` so that npm can find it. This check ensures 88that Git is 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 95 project 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 100checksum that npm uses at install time to verify that the package didn't 101get corrupted in transit. `npm doctor` uses these checksums to validate the 102package tarballs in your local cache (you can see where that cache is 103located with `npm config get cache`). In the event that there are corrupt 104packages in your cache, you should probably run `npm cache clean -f` and 105reset the cache. 106 107### Configuration 108 109#### `registry` 110 111* Default: "https://registry.npmjs.org/" 112* Type: URL 113 114The base URL of the npm registry. 115 116 117 118### See Also 119 120* [npm bugs](/commands/npm-bugs) 121* [npm help](/commands/npm-help) 122* [npm ping](/commands/npm-ping) 123