1

I'm using JointJS as a NPM package and it's working fine. My issue is with managing its dependencies. Right now, it created its own jquery folder inside its own node_modules folder. It's using that jQuery but I have jQuery as a "top level" folder next to JointJS inside my top level node_modules folder. How do I make JointJS use the top level jQuery so I can delete the jquery folder inside JointJS?

ProjectFolder
    node_modules
        jointjs
            node_modules
                jquery (want to delete)
        jquery
xyzen
  • 353
  • 2
  • 12
Tachyon80
  • 147
  • 10
  • I've changed your tags a bit as this question is more related to npm/dependency management as opposed to jointjs/webpack/jquery – xyzen May 27 '19 at 07:17

1 Answers1

1

The short version is to run npm dedupe after you've done your npm install

This will scan your dependency tree and lift/point the nested dependencies to dependencies that sit at the top level your dependency tree where it can.

I say "where it can" because being able to do this will require that the version of jQuery defined in your package.json meets the restrictions of the jQuery version defined in JointJS's package.json. As an example, the v2.2.1 of JointJS requires jQuery 3.3.1 . If your version of jQuery deviates from this at all, npm dedupe will not remove the nested jQuery dependency.

Also remember that other packages you have in your application may have their own versions of jQuery which may also interact with what jQuery ends up in your top level.

In some cases, the jQuery in JointJS will remain nested because it has to remain nested to fulfil all the dependencies and restrictions of your application.

This blog post was immensely useful in helping me understand how npm's dependency resolution works, and why dedupe is needed.

xyzen
  • 353
  • 2
  • 12
  • How many people have succeeded in telling JointJS to like jQuery 3.4.1 instead of 3.3.1? – Tachyon80 May 28 '19 at 14:13
  • The next release looks like it's using 3.4.1 ;) https://github.com/clientIO/joint/blob/master/package.json#L41 – xyzen May 29 '19 at 00:14