npm-doctor.1 4.8 KB

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