选择命令行版本:
🌐 Synopsis
npm explain <package-spec>alias: why
🌐 Description
此命令将打印导致在当前项目中安装给定包的依赖链。
🌐 This command will print the chain of dependencies causing a given package to be installed in the current project.
如果提供了一个或多个包规范,则只有与其中一个说明符匹配的包才会解释它们的关系。
🌐 If one or more package specs are provided, then only packages matching one of the specifiers will have their relationships explained.
该包规范也可以指 ./node_modules 中的一个文件夹
🌐 The package spec can also refer to a folder within ./node_modules
例如,在 npm 的源代码树中运行 npm explain glob 将显示:
🌐 For example, running npm explain glob within npm's source tree will show:
glob@7.1.6node_modules/globglob@"^7.1.4" from the root projectglob@7.1.1 devnode_modules/tacks/node_modules/globglob@"^7.0.5" from rimraf@2.6.2node_modules/tacks/node_modules/rimrafrimraf@"^2.6.2" from tacks@1.3.0node_modules/tacksdev tacks@"^1.3.0" from the root project
要仅解释位于特定文件夹中的包,请将其作为命令的参数传递。当试图弄清楚为什么某个依赖会被重复以满足项目中冲突的版本要求时,这会很有用。
🌐 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.
$ npm explain node_modules/nyc/node_modules/find-upfind-up@3.0.0 devnode_modules/nyc/node_modules/find-upfind-up@"^3.0.0" from nyc@14.1.1node_modules/nycnyc@"^14.1.1" from tap@14.10.8node_modules/tapdev tap@"^14.10.8" from the root project
🌐 Configuration
json是否输出 JSON 数据,而不是正常输出。
🌐 Whether or not to output JSON data, rather than the normal output.
npm pkg set 中,它可以在将值保存到你的 package.json 之前使用 JSON.parse() 解析设置的值。并非所有 npm 命令都支持。
🌐 Not supported by all npm commands.
workspace启用在当前项目的已配置工作区的上下文中运行命令,同时通过仅运行此配置选项定义的工作区进行过滤。
🌐 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.
workspace 配置的有效值为以下之一:
🌐 Valid values for the workspace config are either:
对于 npm init 命令设置时,可以将其设置为一个尚不存在的工作区文件夹,以创建该文件夹并将其作为项目内全新的工作区进行设置。
🌐 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.
此值不会导出到子进程的环境中。
🌐 This value is not exported to the environment for child processes.
🌐 See Also