Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you find out which NPM modules depend on yours?

It's easy to see what modules a specific module depends on but I can't seem to find out how to see what modules depend on a specific module. Is there a simple way to do this? If so, is there a way to do this programmatically?

like image 776
Chev Avatar asked Sep 13 '13 23:09

Chev


People also ask

How do I see npm dependencies?

Use the npm list to show the installed packages in the current project as a dependency tree. Use npm list --depth=n to show the dependency tree with a specified depth. Use npm list --prod to show packages in the dependencies . Use npm list --dev to show packages in the devDependencies .

Where are npm dependencies installed?

npm install (in a package directory, no arguments): Install the dependencies to the local node_modules folder. In global mode (ie, with -g or --global appended to the command), it installs the current package context (ie, the current working directory) as a global package.

What are npm dependencies?

dependencies are the package references that are used by your library without which it cannot work and to be installed along with your library installation automatically. While looking at peerDependencies, npm will just throw a warning message in case the specified packages are not found in node modules.


2 Answers

Update: The registry API has changed, and may or may not let you talk directly to underlying CouchDB database. Fortunately, there is still a public mirror provided for replication at https://skimdb.npmjs.com/registry that you can still send queries to. To use:

https://skimdb.npmjs.com/registry/_design/app/_view/dependedUpon?group_level=3&startkey=%5B"socket.io"%5D&endkey=%5B"socket.io"%2C%7B%7D%5D&skip=0&limit=1000 

For ease of reading, here are the querystring parameters from the example:

{ group_level: 3,   startkey: '["socket.io"]',   endkey: '["socket.io", {}]',   skip: 0,   limit: 1000 } 

Note that as stated above, these are parameters for a CouchDB request. There doesn't seem to be an endpoint on the official API to get this data, but there's an issue open for the registry that you can follow here.


The closest thing you'd get to doing that is probably requesting JSON from the npm registry. For example, to get the packages dependent on Socket.IO, send a GET request to this link:

http://registry.npmjs.org/-/_view/dependedUpon?group_level=3&startkey=%5B%22socket.io%22%5D&endkey=%5B%22socket.io%22%2C%7B%7D%5D&skip=0&limit=1000 
like image 166
hexacyanide Avatar answered Sep 21 '22 06:09

hexacyanide


You can browse them on npmjs.com itself, by going to a URLs like, for example, https://www.npmjs.com/browse/depended/markdown-it

like image 35
Klortho Avatar answered Sep 21 '22 06:09

Klortho