Skip to content
This repository was archived by the owner on Aug 11, 2022. It is now read-only.
This repository was archived by the owner on Aug 11, 2022. It is now read-only.

Feature request: Declare modules as "singleton" #6164

Description

@mantoni

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?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions