npm-doctor.1 5.2 KB

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