Alexander Mills Alexander Mills - 1 year ago 73
Node.js Question

view local NPM packages that depend on package X

I am getting some

warnings for a particular NPM package, in this case the package is "get-cursor-position". I would like to find out which packages in my local node_modules directory depend on this package. (This might not be easy to do).

if I run:

$ npm view get-cursor-position

I get:

{ name: 'get-cursor-position',
description: 'Get the cursor\'s current position in your terminal.',
'dist-tags': { latest: '1.0.3' },
[ '0.0.1',
'1.0.3' ],
maintainers: [ 'bubkoo <>' ],
{ 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: '',
keywords: [ 'terminal', 'console', 'cursor', 'position', 'ansi', 'escape' ],
{ type: 'git',
url: 'git+' },
author: 'bubkoo <>',
bugs: { url: '' },
license: 'MIT',
readmeFilename: '',
version: '1.0.3',
main: 'index.js',
{ test: 'echo "Error: no test specified" && exit 1',
install: 'node-gyp rebuild' },
gypfile: true,
gitHead: '56d403bb0e554532d17c403c47421ce8d2db2dec',
{ shasum: '0e41d60343b705836a528d69a5e099e2c5108d63',
tarball: '' },
directories: {} }

I believe npm view will just look up the remote data for the package, I am happy to use the aggregate data on NPM showing all the packages that depend on
, and I can do some manual work on my end to compare with local packages.

I also tried:

npm ls foo

In my case, I tried:

npm ls suman-events

and it didn't seem to pick up what I expected it to pick up. I would have expected it to pick up "suman-example-reporter" in my case =>

as you can see in the image below, "suman-example-reporter" is a direct dependency in my project (it's in package.json) and suman-example-reporter depends on "suman-events" (and "suman-events" is in package.json as well, because it's also a direct dependency of my project).

enter image description here

Anyone know how to do this right?

Answer Source

The npm ls <options> command is definitely what you want. Here are the docs for the command:

it says

"When run as ll or la, it shows extended information by default."

So to get a full list of dependencies in your project that depend on x, try:

$ npm la x

instead of

$ npm ls x
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download