npm

How can I determine where an NPM's transitive dependency is coming from?


I'm trying to npm install a package, but it's failing to install due to a missing transitive dependency.

(I don't think the details are important, but we're proxying to an Nexus NPM registry, which didn't support scoped modules at the time. One of our dependency's dependencies is trying to pull down the @bahmutov/parse-github-repo-url module, and we get a 404.)

In my npm-debug.log I see the 404 from our registry:

404 - Path /@bahmutov/parse-github-repo-url not found in group repository</title>

But I can't tell which dependency is trying to pull it down.

Normally I'd run npm ls [package-name] but this doesn't work for a project with an empty node_modules folder, which is what's going on here.

We're using npm3, which has a flat dependency tree, so I can't just open up the partially-hydrated node_modules folder and see where things get laid down.

Is there a way to inspect a package.json file and determine the calculated dependency tree without relying on npm install to succeed?


Solution

  • npm-remote-ls looks like it might give you a reasonable answer!