reggi/cache-based-on-version
@reggi/path-to-regexp
dependabot/npm_and_yarn/main/copy-to-clipboard-4.0.2
dependabot/npm_and_yarn/main/eslint-10.4.0
dependabot/npm_and_yarn/main/npmcli/eslint-config-7.0.0
dependabot/npm_and_yarn/main/proc-log-7.0.0
dependabot/npm_and_yarn/npm_and_yarn-826852524d
dependabot/npm_and_yarn/npm_and_yarn-ab9a7f4bc2
deprecate-totp-2fa
dhei/classic-tokens
gat-bypass-2fa-docs
jpg619/fix-accessibility-content-flow
jpg619/version-bump-tar-2
kartykp/gat-bypass-2fa-docs
kartykp/upgrade-path-to-regex
main
maitxn/version-bump-tar
patch-1
reggi/cache-based-on-version
reggi/dev-engines
reggi/fix-transform-prettier
reggi/overrides
update-search-sensitivity
| 1 | --- |
| 2 | title: npm-explain |
| 3 | section: 1 |
| 4 | description: Explain installed packages |
| 5 | github_repo: npm/cli |
| 6 | github_branch: release/v10 |
| 7 | github_path: docs/lib/content/commands/npm-explain.md |
| 8 | redirect_from: |
| 9 | - /cli-documentation/v10/cli-commands/explain |
| 10 | - /cli-documentation/v10/cli-commands/npm-explain |
| 11 | - /cli-documentation/v10/commands/explain |
| 12 | - /cli-documentation/v10/commands/npm-explain |
| 13 | - /cli-documentation/v10/explain |
| 14 | - /cli-documentation/v10/npm-explain |
| 15 | - /cli/v10/cli-commands/explain |
| 16 | - /cli/v10/cli-commands/npm-explain |
| 17 | - /cli/v10/commands/explain |
| 18 | - /cli/v10/explain |
| 19 | - /cli/v10/npm-explain |
| 20 | --- |
| 21 | |
| 22 | ### Synopsis |
| 23 | |
| 24 | ```bash |
| 25 | npm explain <package-spec> |
| 26 | |
| 27 | alias: why |
| 28 | ``` |
| 29 | |
| 30 | ### Description |
| 31 | |
| 32 | This command will print the chain of dependencies causing a given package to be installed in the current project. |
| 33 | |
| 34 | If one or more package specs are provided, then only packages matching one of the specifiers will have their relationships explained. |
| 35 | |
| 36 | The package spec can also refer to a folder within `./node_modules` |
| 37 | |
| 38 | For example, running `npm explain glob` within npm's source tree will show: |
| 39 | |
| 40 | ```bash |
| 41 | glob@7.1.6 |
| 42 | node_modules/glob |
| 43 | glob@"^7.1.4" from the root project |
| 44 | |
| 45 | glob@7.1.1 dev |
| 46 | node_modules/tacks/node_modules/glob |
| 47 | glob@"^7.0.5" from rimraf@2.6.2 |
| 48 | node_modules/tacks/node_modules/rimraf |
| 49 | rimraf@"^2.6.2" from tacks@1.3.0 |
| 50 | node_modules/tacks |
| 51 | dev tacks@"^1.3.0" from the root project |
| 52 | ``` |
| 53 | |
| 54 | 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. |
| 55 | |
| 56 | ```bash |
| 57 | $ npm explain node_modules/nyc/node_modules/find-up |
| 58 | find-up@3.0.0 dev |
| 59 | node_modules/nyc/node_modules/find-up |
| 60 | find-up@"^3.0.0" from nyc@14.1.1 |
| 61 | node_modules/nyc |
| 62 | nyc@"^14.1.1" from tap@14.10.8 |
| 63 | node_modules/tap |
| 64 | dev tap@"^14.10.8" from the root project |
| 65 | ``` |
| 66 | |
| 67 | ### Configuration |
| 68 | |
| 69 | #### `json` |
| 70 | |
| 71 | - Default: false |
| 72 | - Type: Boolean |
| 73 | |
| 74 | Whether or not to output JSON data, rather than the normal output. |
| 75 | |
| 76 | - In `npm pkg set` it enables parsing set values with JSON.parse() before saving them to your `package.json`. |
| 77 | |
| 78 | Not supported by all npm commands. |
| 79 | |
| 80 | #### `workspace` |
| 81 | |
| 82 | - Default: |
| 83 | - Type: String (can be set multiple times) |
| 84 | |
| 85 | 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. |
| 86 | |
| 87 | Valid values for the `workspace` config are either: |
| 88 | |
| 89 | - Workspace names |
| 90 | - Path to a workspace directory |
| 91 | - Path to a parent workspace directory (will result in selecting all workspaces within that folder) |
| 92 | |
| 93 | When set for the `npm init` 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. |
| 94 | |
| 95 | This value is not exported to the environment for child processes. |
| 96 | |
| 97 | ### See Also |
| 98 | |
| 99 | - [package spec](/cli/v10/using-npm/package-spec) |
| 100 | - [npm config](/cli/v10/commands/npm-config) |
| 101 | - [npmrc](/cli/v10/configuring-npm/npmrc) |
| 102 | - [npm folders](/cli/v10/configuring-npm/folders) |
| 103 | - [npm ls](/cli/v10/commands/npm-ls) |
| 104 | - [npm install](/cli/v10/commands/npm-install) |
| 105 | - [npm link](/cli/v10/commands/npm-link) |
| 106 | - [npm prune](/cli/v10/commands/npm-prune) |
| 107 | - [npm outdated](/cli/v10/commands/npm-outdated) |
| 108 | - [npm update](/cli/v10/commands/npm-update) |