rwallace
rwallace

Reputation: 33365

Making sense of npm dependencies

I'm trying to figure out exactly what's going on with npm dependencies.

The shortest specific form of my question is: given that my transitive dependency graph invokes a certain package multiple times with different versions, why are those different versions not showing up in either npm list or the file system?

I don't want to clutter the global namespace with junk just for testing, so will use my actual current project; it's small enough to be clear, I think.

C:\ayane>npm list
[email protected] C:\ayane
+-- [email protected]
| +-- [email protected]
| +-- [email protected]
| +-- [email protected]
| `-- [email protected]
+-- [email protected]
| `-- [email protected]
|   +-- [email protected]
|   +-- [email protected]
|   | `-- [email protected]
|   +-- [email protected]
|   +-- [email protected]
|   | `-- [email protected]
|   |   +-- [email protected]
|   |   `-- [email protected]
|   +-- [email protected]
|   `-- [email protected]
+-- [email protected]
| `-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
`-- [email protected]

That looks fine so far except ayane depends on clause-normal-form 2.4.0 but dimacs-parser and tptp-parser depend on clause-normal-form 2.3.0; why is this not showing in the above?

C:\ayane>tree /a
Folder PATH listing for volume OS
Volume serial number is C685-B1F1
C:.
\---node_modules
    +---.bin
    +---balanced-match
    +---big-integer
    +---big-rational
    +---brace-expansion
    +---clause-normal-form
    +---clone
    +---command-files
    +---commander
    +---concat-map
    |   +---example
    |   \---test
    +---dimacs-parser
    +---fs.realpath
    +---get-stdin
    +---glob
    +---graceful-readlink
    +---inflight
    +---inherits
    +---iop
    +---lodash
    |   \---fp
    +---minimatch
    +---once
    +---path-is-absolute
    +---tptp-parser
    \---wrappy

Same question: why is only one clause-normal-form directory appearing?

Upvotes: 2

Views: 61

Answers (1)

Kalana Demel
Kalana Demel

Reputation: 3266

It is probably because it will only install one version of the same module unless told otherwise. This would be a issue if clause-normal-form version 2.3.0 and 2.4.0 is incompatible, you might run into some trouble if they are. For the best solution so your code works without issues you need to use peerDependencies in the package.json

https://nodejs.org/en/blog/npm/peer-dependencies/

P.S : This does not work on npm version 3 and above, it will only give a warning for us to install them manually

Upvotes: 1

Related Questions