Team Ai
Datasetpublic

codekingpro/portable-devtools

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