npm-explain.1 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. .TH "NPM-EXPLAIN" "1" "March 2026" "NPM@11.12.0" ""
  2. .SH "NAME"
  3. \fBnpm-explain\fR - Explain installed packages
  4. .SS "Synopsis"
  5. .P
  6. .RS 2
  7. .nf
  8. npm explain <package-spec>
  9. alias: why
  10. .fi
  11. .RE
  12. .SS "Description"
  13. .P
  14. This command will print the chain of dependencies causing a given package to be installed in the current project.
  15. .P
  16. If one or more package specs are provided, then only packages matching one of the specifiers will have their relationships explained.
  17. .P
  18. The package spec can also refer to a folder within \fB./node_modules\fR
  19. .P
  20. For example, running \fBnpm explain glob\fR within npm's source tree will show:
  21. .P
  22. .RS 2
  23. .nf
  24. glob@7.1.6
  25. node_modules/glob
  26. glob@"^7.1.4" from the root project
  27. glob@7.1.1 dev
  28. node_modules/tacks/node_modules/glob
  29. glob@"^7.0.5" from rimraf@2.6.2
  30. node_modules/tacks/node_modules/rimraf
  31. rimraf@"^2.6.2" from tacks@1.3.0
  32. node_modules/tacks
  33. dev tacks@"^1.3.0" from the root project
  34. .fi
  35. .RE
  36. .P
  37. To explain just the package residing at a specific folder, pass that as the argument to the command. This can be useful when trying to figure out exactly why a given dependency is being duplicated to satisfy conflicting version requirements within the project.
  38. .P
  39. .RS 2
  40. .nf
  41. $ npm explain node_modules/nyc/node_modules/find-up
  42. find-up@3.0.0 dev
  43. node_modules/nyc/node_modules/find-up
  44. find-up@"^3.0.0" from nyc@14.1.1
  45. node_modules/nyc
  46. nyc@"^14.1.1" from tap@14.10.8
  47. node_modules/tap
  48. dev tap@"^14.10.8" from the root project
  49. .fi
  50. .RE
  51. .SS "Configuration"
  52. .SS "\fBjson\fR"
  53. .RS 0
  54. .IP \(bu 4
  55. Default: false
  56. .IP \(bu 4
  57. Type: Boolean
  58. .RE 0
  59. .P
  60. Whether or not to output JSON data, rather than the normal output.
  61. .RS 0
  62. .IP \(bu 4
  63. In \fBnpm pkg set\fR it enables parsing set values with JSON.parse() before saving them to your \fBpackage.json\fR.
  64. .RE 0
  65. .P
  66. Not supported by all npm commands.
  67. .SS "\fBworkspace\fR"
  68. .RS 0
  69. .IP \(bu 4
  70. Default:
  71. .IP \(bu 4
  72. Type: String (can be set multiple times)
  73. .RE 0
  74. .P
  75. Enable running a command in the context of the configured workspaces of the current project while filtering by running only the workspaces defined by this configuration option.
  76. .P
  77. Valid values for the \fBworkspace\fR config are either:
  78. .RS 0
  79. .IP \(bu 4
  80. Workspace names
  81. .IP \(bu 4
  82. Path to a workspace directory
  83. .IP \(bu 4
  84. Path to a parent workspace directory (will result in selecting all workspaces within that folder)
  85. .RE 0
  86. .P
  87. When set for the \fBnpm init\fR command, this may be set to the folder of a workspace which does not yet exist, to create the folder and set it up as a brand new workspace within the project.
  88. .P
  89. This value is not exported to the environment for child processes.
  90. .SS "See Also"
  91. .RS 0
  92. .IP \(bu 4
  93. npm help "package spec"
  94. .IP \(bu 4
  95. npm help config
  96. .IP \(bu 4
  97. npm help npmrc
  98. .IP \(bu 4
  99. npm help folders
  100. .IP \(bu 4
  101. npm help ls
  102. .IP \(bu 4
  103. npm help install
  104. .IP \(bu 4
  105. npm help link
  106. .IP \(bu 4
  107. npm help prune
  108. .IP \(bu 4
  109. npm help outdated
  110. .IP \(bu 4
  111. npm help update
  112. .RE 0