Node.js 查看依赖于包X的本地NPM包
我得到了一些特定NPM包的Node.js 查看依赖于包X的本地NPM包,node.js,npm,Node.js,Npm,我得到了一些特定NPM包的节点gyp警告,在这种情况下,包是“获取光标位置”。我想找出我的本地node_modules目录中的哪些包依赖于此包。(这可能不容易做到) 如果我跑步: $ npm view get-cursor-position 我得到: { name: 'get-cursor-position', description: 'Get the cursor\'s current position in your terminal.', 'dist-tags': { late
节点gyp
警告,在这种情况下,包是“获取光标位置”。我想找出我的本地node_modules目录中的哪些包依赖于此包。(这可能不容易做到)
如果我跑步:
$ npm view get-cursor-position
我得到:
{ name: 'get-cursor-position',
description: 'Get the cursor\'s current position in your terminal.',
'dist-tags': { latest: '1.0.3' },
versions:
[ '0.0.1',
'0.0.2',
'0.0.4',
'0.0.5',
'1.0.0',
'1.0.1',
'1.0.2',
'1.0.3' ],
maintainers: [ 'bubkoo <bubkoo@163.com>' ],
time:
{ modified: '2016-11-01T02:36:07.728Z',
created: '2016-03-05T03:42:31.517Z',
'0.0.1': '2016-03-05T03:42:31.517Z',
'0.0.2': '2016-03-07T00:35:36.627Z',
'0.0.4': '2016-03-10T07:21:21.364Z',
'0.0.5': '2016-03-10T07:25:04.846Z',
'1.0.0': '2016-04-16T08:11:34.546Z',
'1.0.1': '2016-06-03T15:57:55.767Z',
'1.0.2': '2016-06-13T14:19:32.966Z',
'1.0.3': '2016-11-01T02:36:07.728Z' },
homepage: 'https://github.com/bubkoo/get-cursor-position',
keywords: [ 'terminal', 'console', 'cursor', 'position', 'ansi', 'escape' ],
repository:
{ type: 'git',
url: 'git+https://github.com/bubkoo/get-cursor-position.git' },
author: 'bubkoo <bubkoo.wy@gmail.com>',
bugs: { url: 'https://github.com/bubkoo/get-cursor-position/issues' },
license: 'MIT',
readmeFilename: 'README.md',
version: '1.0.3',
main: 'index.js',
scripts:
{ test: 'echo "Error: no test specified" && exit 1',
install: 'node-gyp rebuild' },
gypfile: true,
gitHead: '56d403bb0e554532d17c403c47421ce8d2db2dec',
dist:
{ shasum: '0e41d60343b705836a528d69a5e099e2c5108d63',
tarball: 'https://registry.npmjs.org/get-cursor-position/-/get-cursor-position-1.0.3.tgz' },
directories: {} }
就我而言,我尝试:
npm ls suman-events
而且它似乎没有得到我所期望的结果。在我的案例中,我希望它能找到“suman示例记者”=>
如下图所示,“suman example reporter”在我的项目中是一个直接依赖项(在package.json中),而suman example reporter依赖于“suman事件”(而“suman事件”也在package.json中,因为它也是我的项目的一个直接依赖项)
有人知道怎么做吗 正如Ryan在评论中所建议的,将显示与指定包相关的依赖关系树,以便您可以查看哪些包直接/间接需要它 例如,如果您安装
rimraf
,once
是一个依赖项,您可以查看是哪个软件包导致安装它:
$ npm ls once
yourpackage@1.0.0 /path/to/pkg
└─┬ rimraf@2.5.4
└─┬ glob@7.1.1
└── once@1.4.0
因此,您可以看到一次安装,因为glob
需要它,而rimraf
(我在包中指定了它。json
)依赖于glob
如果需要扩展信息,请使用npmls--long
(或者它的简写语法,npmla
/npmll
)。扩展输出还将包括模块描述、Git repo链接、自述,并且肯定会包括树中的每个模块(一些模块可能会被基本的npm ls跳过)。npmjs.com上的页面列出了所有依赖的包。在本例中,它们只有5个。npm ls
命令绝对是您想要的
@奥罗拉的答案基本上是正确的
以下是该命令的文档:
上面说
当以ll或la运行时,默认情况下会显示扩展信息
因此,要获得项目中依赖于x的依赖项的完整列表,请尝试:
$ npm la x
而不是
$ npm ls x
npm ls是否获得光标位置
工作?我不记得了。OP似乎已经知道了这一点,他们并不真的想要它-他们想在本地为他们的包.json
做这件事。好的,如果这是一个编程解决方案,让我试试,确保它能工作,在我验证这是好的之后,它会接受答案,但它似乎没有那么好工作,我在实验中看到过一些例子,它没有拾取可能应该确定的东西,所以看起来你真的想要“npm la once”,这将显示一个扩展list@AlexanderMills我已经用关于npm la的更多细节更新了我的答案-这有用吗?
$ npm ls x