First of all, I love the fact that npm allows me to have several versions of the same package installed.
However, here's the thing:
I use npm for browser and node packages and run npm dedupe after installs to make sure to have as few dupes as possible (my tree has more than 300 modules). Having dupes (especially with major version changes) is fine in most cases, but for some modules this is not acceptable. For example, a module that instantiates a WebSocket connection with the node backend should never be loaded twice. Or on the node side, I never want a module loaded twice that connects to a queue or starts listening on a specific port.
Currently, I have to put horrible hacks into my code to prevent this from happening at runtime, but an "install time" failure could make the CI build fail.
npm already warn about unresolvable dupes, but I want npm dedupe to actualy fail if there are dupes for these kind of modules.
My suggestion would be to add a singleton : true property to the package.json (or any other flag) and if a package with that property has dupes, npm dedupe has an exit code other than 0.
Thoughts?
First of all, I love the fact that npm allows me to have several versions of the same package installed.
However, here's the thing:
I use npm for browser and node packages and run
npm dedupeafter installs to make sure to have as few dupes as possible (my tree has more than 300 modules). Having dupes (especially with major version changes) is fine in most cases, but for some modules this is not acceptable. For example, a module that instantiates a WebSocket connection with the node backend should never be loaded twice. Or on the node side, I never want a module loaded twice that connects to a queue or starts listening on a specific port.Currently, I have to put horrible hacks into my code to prevent this from happening at runtime, but an "install time" failure could make the CI build fail.
npm already warn about unresolvable dupes, but I want
npm dedupeto actualy fail if there are dupes for these kind of modules.My suggestion would be to add a
singleton : trueproperty to the package.json (or any other flag) and if a package with that property has dupes,npm dedupehas an exit code other than0.Thoughts?